Using a function in a view
I have to include a function in a view. I want to create a new column in a view which is the output of this function. Can I do it. I am new to using functions..any sample code is appreciated..
Hi,
Yes of corse.
REgards salim.SQL> CREATE OR REPLACE FUNCTION div (sal NUMBER)
2 RETURN REAL
3 IS
4 BEGIN
5 RETURN (sal / 2);
6 END;
7 /
Fonction créée.
SQL> create or replace view v_emp as
2 select empno,ename,sal,div(sal) sal_div
3* from emp_test
SQL> /
Vue créée.
SQL> select * from v_emp;
EMPNO ENAME SAL SAL_DIV
7698 BLAKE 20000 10000
7566 JONES 5950 2975
7699 DAVID 20000 10000
7782 CLARK 20000 10000
7839 KING 10000 5000
7902 FORD 6000 3000
7788 SCOTT 6000 3000
7 ligne(s) sélectionnée(s).
SQL>
Similar Messages
-
INDEX on VIEW or TABLE when using CONTAINS function on the VIEW
Hi,
I'm querying a view with a contains function and I'm getting an error:
query: select * from view where contains(name,'jack OR jill')>0
ORA-20000: Oracle text error
DRG-10599 column is not indexed.
From what I gathered you can't create an index on the view, or is that possible afterall (using 10g).
Would it be sufficent to create an index on the column in the table that the view-query is pulling the data from? or can you use the contains funtion on views at all?
Or are there other ways of doing this better?
Thanks,That particular CONTAINS clause will require a domain index on the column, NAME in your case.
You could also do: select * from view where name in ('Jack', 'Jill')
Depending on your need and number of records and other variables, it may be "fastest" to do the text index on the NAME column. If it is a rather small subset of data and performance is not critical then the IN clause should suffice. -
Using analytic function in a view
Hello to all
Sorry If I use this thread
sql not merge using analytic functions
for my question,
From example you write and from Tom explain is not possible create a view on analytic function?
Thanks and sorry againI think what you'll discover is that if you apply the function over the result set, the initial SQL might be quicker,
for example, this is a test I did with a large dictionary view:
select tp.Table_Name
,tp.Partition_Name
from
select tbl.Table_Name as Table_Name
,tbl.Partition_Date as dt
,row_number() over (partition by dtp.table_Name order by dtp.Partition_Name desc) rn
from (
select /*+ all_rows */
dtp.Table_Name
,dtp.Partition_name
from dba_tab_partitions dtp
where dtp.Partition_Name like 'Y____\_Q_\_M__\_D__' escape '\'
and dtp.Table_Owner = 'APPS'
and dtp.Table_name not like '%$%'
and dtp.Table_Name like '%'
) tbl
) tp
where tp.rn = 1
select Table_Name
,Partition_Name
from (
select /*+ all_rows */
dtp.Table_Name
,row_number() over (partition by tbl.table_Name order by tbl.Partition_Name desc) rn
from dba_tab_partitions dtp
where dtp.Partition_Name like 'Y____\_Q_\_M__\_D__' escape '\'
and dtp.Table_Owner = 'APPS'
and dtp.Table_name not like '%$%'
and dtp.Table_Name '%'
) tbl
where rn = 1I found the former to be quicker.
I think ask tom was saying a lot more, but included something similar,
Edited by: bluefrog on Jun 10, 2010 12:48 PM -
Use Aggregate Functions in a View
Is it possible to create a view in SE11 using an aggregate SQL function?
I.e., I want the generated SQL to look like:
CREATE VIEW z_tbl
A,
SUM_AMT
AS SELECT
A,
SUM(AMT)
FROM TBL
GROUP BY A
Thanks for any help.Executes the Native SQLstatements enclosed between EXEC SQL and ENDEXEC statements. Unlike Open SQLNative SQL statements can address tables that are not declared in theABAP Dictionary.
Example
Creating the Table AVERI_CLNT:
EXEC SQL.
CREATE TABLE AVERI_CLNT (
CLIENT CHAR(3) NOT NULL,
ARG1 CHAR(3) NOT NULL,
ARG2 CHAR(3) NOT NULL,
FUNCTION CHAR(10) NOT NULL,
PRIMARY KEY (CLIENT, ARG1, ARG2)
ENDEXEC. -
Can anyone tell how to use daysbetween() function in analytical view?
I have been trying to create a calculated column in analytical view. Column needs to calculate days between two dates.
Using daysbetween (date1,date2) function, I have been trying to bring the difference but while validating i m getting error as date 1 is not an attribute.
Infact, I am using fields from my column itself but still not able to move further. Please help
Regards,
Vikram SharmaHi Peter,
The datatype is date, initially it was NVARCHAR type but i wanna keep it to date type so i changed it.
However, the query that you have given will calculate days from current date, right?. I have one date as a column in a table and another date is from input parameter.
So I need to calculate days lapse between two specified dates in which i have been unsuccessfull so far..
Also, just for your info. when i used this date function in HANA SPS 07 it was working fine but don't know what happen now when I am using it in SPS08.
Regards,
Vikram -
Using "Comlplete" function in Basic View
We have a Task List with 15 Data Forms that need to be cycled through as part of our budget process. We have an end user responsible for 5 departments. If the end user goes to the Data Form 1 for department 1 and enters their data, they then mark it as Complete using the box at the bottom of the Data Form. When they go to department 2 (using the drop down on Data Form 1) it is also marked as Complete. Is that normal? Or do we need to change a setting? What I am looking for is the abilty to use the Complete on just Data Form 1 with department 1. When I go to Data Form 1 for department 2 I am looking to see it as Incomplete. Is that possible?
Thx in advance.
Edited by: user8374782 on Aug 22, 2012 2:15 PMHi,
It is working as expected.
The "*mark complete*" helps user to identity the completed task, which means feeding data in all the departments in your case.
User will mark the data feeding task as complete, only when he/she is done with all data feeding in a particular web form and he/she is set to move to next task.
What I am looking for is the abilty to use the Complete on just Data Form 1 with department 1. When I go to Data Form 1 for department 2 I am looking to see it as Incomplete. Is that possible?I think the above requirement of yours might not possible.
Regards
-SM
Edited by: 918547 on Aug 22, 2012 11:58 PM -
Can not use TOUCH function on Nokia 6600 slide
Can not use TOUCH function on Nokia 6600 slide-
turned on sensor in phone settings, but when i touch the PHONE it does not work.
Please, tell me how use this function or maybe my phone is out of orderAs long as your Sensor Settings are On within Menu, Settings, Phone, Sensor Settings then you just need to do the following -
Tapping
The tap function allows you to quickly
mute and reject calls and alarm tones, and
to display a clock just by double-tapping
the back or front of the phone when the
slide is closed.
Select Menu > Settings > Phone >
Sensor settings to activate the tap
function and vibration feedback.
Mute calls or alarms
Double-tap the phone.
Reject a call or snooze an alarm after
muting it
Double-tap the phone again.
Display the clock
Double-tap the phone.
(If you have missed calls or received new
messages, you must view them before you
can see the clock.)
Simply, if you double tap the screen when the slide is closed and you can see the clock appear then it is working.
I hope this makes it clearer for you.
Full Manual here - http://nds1.nokia.com/phones/files/guides/Nokia_6600_slide_UG_en.pdf -
Hi all,
is it possible to view mails send using SO_NEW_DOCUMENT_ATT_SEND_API1 function module to UWL?
I am receving emails in my SAP Inbox.
Please guide.
thanks.Hi,
You can only get the SAP mails into UWL notification tab with the Sonic connector (well of course with some custom development everything is possible).
One trick to get the workflow for sending "mails" to UWL is to NOT use email sending step, but instead use a decision step in the workflow and send this work item to the user. The decision step can include the same message as the email, and have onl one option "Confirm" (or whatever). These you can easily display in UWL since they are normal work items.
Regards,
Karri -
How to use this FUNCTION VIEW_MAINTENANCE
hi
i create a table zxxxx and set Data Browser/Table View Maint:
Display/Maintenance Allowed.
so i want to use the function of "VIEW_MAINTENANCE" to update and create new
inforation the TABLE.
but i don't know VIEW_MAINTENANCE which of parameter meaning.
and how to control it.
who can give demo show.
CALL FUNCTION 'VIEW_MAINTENANCE'
EXPORTING
VIEW_ACTION = 'S' "DISPLAY
VIEW_NAME = W_VIEWNAME "W_TABNAME
TABLES
X_HEADER = L_VIMDESC
X_NAMTAB = L_VIMNAMTAB
DBA_SELLIST = L_VIMSELLIST
EXCL_CUA_FUNCT = L_VIMEXCLFUN.
what meaning and availability value : EXCL_CUA_FUNCT-FUCNTION ,
how to use X_HEADER
X_NAMTAB
DBA_SELLIST these parameter.
thank you very much.Please check doucmentation maintained for FM - VIEW_MAINTENANCE.
CUA functions to be deactivated dynamically
At runtime, the table EXCL_CUA_FUNCT must contain all those functions which are not to be callable in data processing , i.e. which are to be dynamically deactivated in the CUA interface at runtime. This is useful, e.g. for the following functions whose handling in cluster maintenance is ambiguous:
- 'ANZG' --> switch from 'Change' to 'Display' mode,
makes no sense in a maintenance cluster
- 'AEND' --> switch from 'Display' to 'Change' mode
makes no sense in a display cluster
- 'xxxx' --> other functions at the callers discretion.
The table must have the structure VIMEXCLFUN, as follows:
FUNCTION(4) TYPE C, ---> contains the function codes to be deactivated dynamically
MESSAGE(3) TYPE C. ---> online help auxiliary field (not yet supported)
Return ->
CUA functions to be deactivated dynamically
Database Access Selection Conditions The table DBA_SELLIST contains the database access selection conditions. The following fields must be filled:
Field name Contents
NEGATION NOT, if the condition is to be negated
SPACE otherwise
VIEWFIELD name of the field to which the condition is to apply
OPERATOR logical operator of the condition (e.g. 'EQ', 'NE',...)
VALUE comparison value of the condition in external format
AND_OR AND, if the next line of the condition is to be linked
to the current line by logical AND
OR , if the next line of the condition is to be linked
to the current line by logical OR
SPACE, if no further line follows
DDIC S, if the view field in DD is flagged as a subset field
(PM = 'S')
SPACE otherwise
TABIX Index of the view field in the view nametab
Notes:
1. Valid operators are: (see also ABAP doc.)
EQ - equals
NE - not equal to
GT - greater than
GE - greater than or equal to
LT - less than
LE - less than or equal to
CA - only for strings: contains at least one character of the comparison string
CN - only for strings: negation of CA
CO - only for strings: contains only characters from the comparison string
NA - only for strings: negation of CO
CP - only for strings: contains the pattern in the comparison string
NP - only for strings: negation of CP
CS - only for strings: contains the string in the comparison string
NS - only for strings: negation of CS
LK - like the LIKE operator in a SELECT ... WHERE clause
2. The function module does not (yet) check whether the selection conditions passed here are compatible with any conditions in the Data Dictionary view definition. The caller must ensure that this is the case.
Return ->
Database Access Selection Conditions -
How to use a function PIPELINED in Forms 10g?
Hi guys,
When I tried to use a function PIPELINED in Forms, I received the message:
- PL/SQL function called from SQL must return value of legal SQL Type
FOR rec_dev IN (SELECT *
FROM TABLE(p1196.f_executa('01-aug-2010', -- pdDataInicial
'30-aug-2010', -- pdDataFinal
5, -- pnCodAdm
NULL, -- pnCdsCod
NULL, -- pnAdmsSrvCod
NULL, -- pnAcao
NULL)))
LOOP
vnQtdeEstornos := vnQtdeEstornos + rec_dev.qtde_estornos;
vnVlrTotalCredito := vnVlrTotalCredito + rec_dev.valor_credito;
END LOOP;
Can anyone help me?
CrisYou can't. One option would be to wrap your pipelined function in a view, or you could write a stored procedure which returns a strong ref cursor instead.
cheers -
Using a function return in an "IN" statement
All,
I need to filter the records in a table based on the return value of a function. The function determines a person's group and then executes 2 separate select statements depending on the group.
CREATE OR REPLACE PACKAGE pkg_rolebased
AS
CURSOR all_dmn_cur
IS
SELECT dmn_id
FROM tomwojeck.pa_domain ;
CURSOR child_dmn_cur (role_id_in IN varchar)
IS
SELECT distinct r.dmn_id
FROM tomwojeck.pa_domain_restriction_domain r
WHERE r.dmn_restriction_id IN (
SELECT DISTINCT a.dmn_restriction_id
FROM tomwojeck.pa_role_wf_entity_fct_access a
WHERE a.role_id = role_id_in
AND a.workflow_entity_fct_id= 'View Student.Student.View'
AND a.dmn_restriction_id IS NOT NULL);
FUNCTION rolelookup (stud_email IN varchar)
RETURN roletable;
END;CREATE OR REPLACE PACKAGE BODY pkg_rolebased
IS
FUNCTION rolelookup (stud_email IN varchar)
RETURN roletable
IS
v_roleid varchar2(200);
v_returnval varchar2(200);
v_data roletable := roletable ();
dmn_rec all_dmn_cur%ROWTYPE;
BEGIN
-- Find out the role of the person
SELECT r.role_id
INTO v_roleid
FROM tomwojeck.pa_user_prfl p, tomwojeck.pa_user_prfl_role r
WHERE p.user_name = r.user_name
AND UPPER (p.email_addr) = UPPER (stud_email);
IF UPPER (v_roleid) = 'ALL'
THEN
OPEN all_dmn_cur;
LOOP
FETCH all_dmn_cur
INTO dmn_rec;
v_data.EXTEND;
v_data (v_data.COUNT) := dmn_rec.dmn_id;
EXIT WHEN all_dmn_cur%NOTFOUND;
END LOOP;
CLOSE all_dmn_cur;
ELSE
OPEN child_dmn_cur (v_roleid);
LOOP
FETCH child_dmn_cur
INTO dmn_rec;
v_data.EXTEND;
v_data (v_data.COUNT) := dmn_rec.dmn_id;
EXIT WHEN child_dmn_cur%NOTFOUND;
END LOOP;
CLOSE child_dmn_cur;
END IF;
RETURN v_data;
END rolelookup;
END;
The select statement to filter on this mess is:
select
lname,
fname,
dmn_id,
stud_id
from tomwojeck.pa_student p
where p.DMN_ID in (select * from table(cast(tomwojeck.pkg_rolebased.rolelookup('[email protected]') as tomwojeck.RoleTable)))
The problemm is this performs horribly! If I enter an email address that causes the first cursor to be used, it runs well, but if I use an email address that causes the second cursor to run, it takes forever.
Is there a better way to do this?
Thanks,
Tom Wojeck<<The version of Oracle is 9i.>>
Could you specify the exact version? For example, 9.2.0.3.0.
<<I'm not sure of the query optimizer version. How do I find that?>>
SQL> show parameter optimizer_mode
NAME TYPE
VALUE
optimizer_mode string
CHOOSE<<The interestin thing is that the function itself runs well; it's when I try to use the function as an "IN" clause that the performance degrades. It almost seems as though the database is retrieving each row from the student table, and then running the function to see if there are any matches. >>
Your query has to be tuned. The execution plan as well as the information on the indexes will certainly help. -
Error while using the function module..pack_handling_unit_dlvry
Hi all...
while using the function module pack_handling_unit_dlvry,
we need to pass the handling unit number as per the functionality we require.
but the mandatory field for the function module is the handling unit number in the form of bar code..
so how to use this function module..
All the useful answers will be regarded..
Regards,
Saroja.Have you tried using BAPI BAPI_HU_CREATE. Also view Function Module Documentation on its usage.
-
Using hsgetvalue function to retrieve Hyperion Planning Data
Hi All,
Lots of discussion about hsgetvalue, but still I do not succeed in using this function. Maybe someone can help.
Is this function work for HFM or also Hyperion Planning? Currently we are using Hyperion Planning 11.1.1.3 with related Essbase. This is what we've tried in Excel:
=hsgetvalue(“";”Scenario#BudFin;Year#FY12;Period#Begbalance;Partner#NA_Partner;Product#A251;Account#BOM Weight;Version#Working;Misc#R-SBDA;Entity#No Entity;Currency#Qty") ===> the result is syntax error.
=hsgetvalue("","Scenario#BudFin","Year#FY12","Period#Begbalance","Partner#NA_partner","Product#A251","Account#BOM Weight","Version#Working","Entity#No Entity","Currency#Qty","Misc#R-SBDA") ===> the result is No Connection.
Actually I'm still confused about the Connection parameter, which connection name we have to use?
Thanks.
GajahHi,
HsGetValue
Data sources: Financial Management, Hyperion Enterprise, Essbase
HsGetValue retrieves data from the data source for selected members of a dimension. When HsGetValue retrieves no data, the value specified for the #NoData/Missing Label replacement option is used.
When users select Refresh or Refresh All, only HsGetValue is called. When users select Submit, HsSetValue is called first, HsGetValue is then called only if HsSetValue returns successfully.
Syntax
HsGetValue(“Connection”,”POV”)
Connection parameters can have these values:
Empty: the default connection
HsActive: the active associated connection
The user-defined name for a private connection
You connect to data sources through shared or private connections.
_# Shared Connections_
Shared connections are stored in a central location and are available to multiple users through the Smart View Panel. You cannot add, edit, or rename shared connections, but you can save them as private connections, which you can edit and rename.
_# Private Connections_
Private connections are those that you create by saving a shared connection to your local computer or by entering a URL to a provider that is not configured for shared connections. When you create a private connection, it becomes the active connection.
Creating Private Connections
You can create a private connection from a connection that is not listed in Shared Connections if you know the URL.
To add a connection using a URL:
1. From the Smart View ribbon, click Panel.
2. From the Smart View panel, click the arrow next to "Home" Icon, and then select Private Connections.
3. In the text box, enter the URL or the local storage directory for the data source to which you want to connect. The URL syntax for the various data sources is as follows.
Financial Management: http(s)://servername:port/hfmofficeprovider/hfmofficeprovider.aspx
Hyperion Enterprise: http://servername:port/heofficeprovider/heofficeprovider.aspx
Planning: http(s)://servername:port/HyperionPlanning/SmartView
Essbase: http(s)://servername:port/aps/SmartView
Reporting and Analysis: http(s)://servername:port/raframework/browse/listxml
Financial Close Management: http://servername:port/fcc/servlets/smartview/fcmsvservlet
Oracle Hyperion Strategic Finance: http://servername:port/StrategicPlanning/SmartView
4. Click Next Button
5. Enter the Name of the connect as "Essbase_Conn"
6. Enter username, password and connect the worksheet.
Now you can create functions by two methods -
1. Using Function Builder
2. Manually (Which you have opted)
To create a function manually:*
1. In Excel, click the cell in which you want to enter the function.
2. Enter = (equal sign).
3. Enter the function name, HsGetValue, for example.
4 Enter parameters for the function,
HsGetValue(“Connection”,”POV”)
Connection parameters can have these values:
# Empty: the default connection
# HsActive: the active associated connection
# The user-defined name for a private connection
so the function looks like this:
HsGetValue(“Essbase_Conn”;"Year#Jan;Measures#Sales;Product#100;Market#East;Scenario#Actual")
5. To refresh the worksheet, from the Smart View menu, select Refresh. Functions are validated only when you refresh them.
REFERENCE: Chapter 2 & Chapter 15 of the SmartView Guide at http://docs.oracle.com/cd/E17236_01/epm.1112/sv_user.pdf
KosuruS
Edited by: KosuruS on Jul 12, 2012 9:55 AM -
Using packaged functions in Apex
Hi,
I'm fairly new to apex and I am about to write an app which needs to access a SQL server database. My local dba has set up the transparent gateway and I can select from and update the SQLServer database no problem via a db link. What I need to decide is whether to code the sql for reports etc directly into the apex page or to call a pl/sql function returning a select statement. I would like to have all the code in packages as a lot of it will be used by multiple apps in future but is there any extra overhead in doing this:
declare
l_sql varchar2(4000);
begin
select package.function into l_sql from dual;
return l_sql;
end;
rather than coding the SQL directly in the page? Also is there a more efficient way of using packaged functions to select data rather that just have it returning sql statements.
Thanks in advance.
DaveHi
I only use function returning select when I have a strong reason to do so, because it is so much more difficult to test and maintain. Not sure about performance, but I think it is not that much worse.
If you simply want to reuse SELECT statements, you could use views instead.
Anyway, if you decide to use the package solution, at least you can make it much simpler -- just code like this in the page:
return package.function;
I hope this helps.
Luis -
How to use the function module 'HR_ES_FEATURE_BACKFIELD'
Hi,
How to use the function module 'HR_ES_FEATURE_BACKFIELD'?
I need the usage from both technical as well as functional point of view.
What is the use of this function module and technically how it is to be used to retrieve a feature for a particular employee.hey iam from functional side can u be little bit clear of that feature
thanks
sikindar
Maybe you are looking for
-
Restrict the LONG RAW Column with less than 32760 bytes in the SELECT
When i am trying to access a LONG RAW Dataype wchich has characters greter than 32760 bytes i am getting this error. Error -6502: ORA-06502: PL/SQL: numeric or value error I came to know that PL/SQL will only be able to access the first 32760 bytes o
-
2 step confirmation agent determination error
Hi everyone! We have a prod issue where a 2step app confirmation workflow has failed to determine the responsible agent. This has been working correct for years. Using bbp_pd, the workflow shows no error message. There's a workitem number created but
-
Vertical ScrollBar for JTable disappears when trying to scroll!
Hi! I have 2 JTables and these are in a JScrollPane. I need to add a Vertical ScrollBar in such a way that when the number of rows increases, the scrollbar will scroll both the table's data. I am not using the Vertical ScrollBar of the ScrollPane ins
-
Selecting item in the menu ring will disable in the another menu ring
hi everyone, I using 8 dialog check box and 8 menu ring (Items 1,2,3,4).If i make the 8 dialog check box 'true' condition the corresponding menu rings will enabled .In that menu ring the selected item (1 or 2 or 3 or 4) will d
-
Pl help with simple pl/sql quey
Hi , I am getting stuck with this simple pl/sql query , can anyone pl help me with this. This is the query i have, select ia.deal_id, actual_clear_dt from inc_site_freq isf join INC_ASSET ia on isf.inc_asset_id = ia.inc_asset_id and freq in (866.0125