How to call user fuction in select statement.
hi,
i am facing some problem.How to call user functions in select statement.please send me answer with example.
Thanks
Gopal
Locations to Call User-Defined Functions
• Select list of a SELECT command
• Condition of the WHERE and HAVING clauses
• CONNECT BY, START WITH, ORDER BY, and GROUP
BY clauses
• VALUES clause of the INSERT command
• SET clause of the UPDATE command
Restrictions on Calling Functions from SQL Expressions
To be callable from SQL expressions, a user-defined
function must:
• Be a stored function
• Accept only IN parameters
• Accept only valid SQL data types, not PL/SQL
specific types, as parameters
• Return data types that are valid SQL data types,
not PL/SQL specific types
• Functions called from SQL expressions cannot
contain DML statements.
• Functions called from UPDATE/DELETE statements
on a table T cannot contain DML on the same table
T.
• Functions called from an UPDATE or a DELETE
statement on a table T cannot query the same table.
• Functions called from SQL statements cannot
contain statements that end the transactions.
• Calls to subprograms that break the previous
restriction are not allowed in the function.
jeneesh
Similar Messages
-
Can we call a procedure in select statement?
Can we call a procedure in select statement?
Hi,
Raghu_appsdba wrote:
Can we call a procedure in select statement?No. You can call functions, but not procedures.
If the procedure does not change the database state (for example, it doesn't update any tables), then you can wrap it in a function, or re-write it as a function.
Here's an example of wrapping.
CREATE OR REPLACE FUNCTION fun_x (in_txt IN VARCHAR2)
RETURN VARCHAR2
IS
BEGIN
proc_y (in_txt);
RETURN in_txt
END fun_x; -
How to put OR clause in SELECT statement
Hi
How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
<pre>
SELECT
a.id ,
flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
</pre>
Thsi will return this as exact match.
ADDRESS 1
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
ADDRESS2
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
However this only matches number_first.
How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.Hi, I have a hard time understanding your request, and below is what I thought you want:
SELECT
a.id ,
flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
AND (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
(decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
Edited by: PhoenixBai on Aug 26, 2010 11:33 AM -
Unable to call local function in select statement.
Hi all,
I am unable to call the local function in select statement in below scenario.
DECLARE
l_cnt NUMBER;
FUNCTION FUN1 RETURN NUMBER
AS
BEGIN RETURN 2;
END;
BEGIN
SELECT FUN1 INTO l_cnt FROM DUAL;
DBMS_OUTPUT.PUT_LINE(l_cnt );
END;
/Any alternate way to call local function in select statement?
Thanks
Ram.Hi,
Sorry, you can't call a locally defined function in a SQL statement, even if that SQL statement is in a PL/SQL block where the function is in scope.
This applies to packages, also. If a function is not declared in the package spec, but only in the package body, then you can't call it from SQL statements in the package body.
Why do you want a locally defined function? Why not a function defined outside the procedure? -
How to find what are the select statements fired on a particular schema
Hi Guys,
I have a development box schema whose username and the password is shared across many users who are doing the developement.
I wnat to know what are the select statement fired on it during a particular time interval.
Thanks,
Prafullawith dba user
BEGIN
DBMS_FGA.ADD_POLICY(object_schema => 'schemaname',
object_name => 'CALLS',
policy_name => 'CALLS_AUDIT',
statement_types => 'SELECT'
…enable => TRUE);
END;
then all select are viewed on table dba_fga_audit_trail
Edited by: Adigozalov Gurban on Dec 3, 2010 11:05 AM -
How to call rfc fuction module designed in sap from netweaver
Hi all.
Can any one pls let me know how to call the trfc,arfc function modules designed in sap from netweaver system.
Is the method of calling trfc , arfc fuction modules from non sap system same?
If not let me know how to call trffc & arfc function modules from non sap systems.Thanks in advance.
Kind Regards,
sami.Hi
Use
in background task
and
destination
additions when you call tRFC function modules from
SAP system to SAP system. -
Delete adjacent duplicates how to use in the below select statement
hi i have a problem
i am suing the below select statement
SELECT a~extno
a~guid_lclic " for next select
e~ctsim
e~ctsex
*revised spec 3rd
f~guid_pobj
f~amnt_flt
f~amcur
f~guid_mobj
e~srvll "pk
e~ctsty "PK
e~lgreg "PK
INTO TABLE gt_sagmeld
FROM /SAPSLL/LCLIC as a
INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
inner join /sapsll/legcon as f on fguid_lclic = aguid_lclic " for ccngn1 selection
inner join /sapsll/corcts as g on gguid_pobj = fguid_pobj
where a~extno in s_extno.
sort gt_sagmeld by guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ.
delete adjacent duplicates from gt_sagmeld comparing guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ .
now i am confused how to use delete adjacent dupliacate and on which fields
as first table /sal../lclic primary key is guid_lclic
and it is joined to table
legcon by guid_lclci ( not a primary key here)
legcon primary key is guid_legcon
and table 3 legsv by lgreg (pk here)
table 3 has tow more primary key srvll and ctsty also
NOW MY QUESTIO IS TAHT IS I USE ABOVE DELETE ADJACENT STATMENT IT FETCHES 20 LAKH RECORDS
I WANT TO REDUCE IS LET ME KNOW ON WHAT fields i need to use delete adjacen duplicates
or use comparing all fields?
regards
Arorahi sudha
if u see my select statement is contains four Primary keys
srvll
lgreg
ctsty
guid_lclic
but the next table connected to this table legcon is by guid_pobj and anothe table by guid_mobj
and if i take this gt_sagmeld to another temp table and i find abt 10 lakh uniques guid_pobj
similary 6 lakh guid_mobj so the next slect is hanpering because of this
not COMING TO OUR POINT IF I SORT ONLY BY OUR PRIMARY KEYS NOT TAKING INTO ACCOUNT TEH GUID_POBJ AND GUID_MOBJ
THE ENTRIES ARE VERY LESS BUT IF I TAKE INOT ACCCOUNT IN GT_SAGMELD THE ENTRIES ARE ABT 20 LAKH
SO I AM NOT SURE WHETHER TO TAKNE GUID_POBJ AND GUID_MOBJ INOT ACCOUNT FOR DELECTING ADJACENT DUPLICATES?
HENCE THE QUESTION OF ON WHICH FIRLD DELETE OR COMPARING ALL FIELDS I USE? -
How display number of row in select statement
How can I display number of row in select statement?
Table
data1 data2
xxx ccd
wss qwe
qws uij
I need get from SELECT statement:
1 xxx ccd
2 wss qwe
3 qws uijuser13734495 wrote:
Thank you from answer.
Statement
select rownum rn, data1, data2 from table
is good.
And what have I do went I use
select rownum rn, data1, data2 from table order by data1
and I get
3 qws uij
2 wss qwe
1 xxx ccd
I need
1 qws uij
2 wss qwe
3 xxx ccdhence the importance of describing the complete problem.
select
rownum,
data1,
data2
from(
select
data1,
data2
from
table
order by
data1) -
How to insert variable value using select statement - Oracle function
Hi,
I have a function which inserts record on basis of some condition
INSERT INTO Case
Case_ID,
Case_Status,
Closure_Code,
Closure_Date
SELECT newCaseID,
caseStatus,
Closure_Code,
Closure_Date,
FROM Case
WHERE Case_ID = caseID
Now i want new casestatus value in place of select statement caseStatus value. I have a variable m_caseStatus and i want to use the value of this variable in above select statement.
how can i use this.
thanksHi,
I have a function which inserts record on basis of some condition
INSERT INTO Case
Case_ID,
Case_Status,
Closure_Code,
Closure_Date
SELECT newCaseID,
caseStatus,
Closure_Code,
Closure_Date,
FROM Case
WHERE Case_ID = caseID
Now i want new casestatus value in place of select statement caseStatus value. I have a variable m_caseStatus and i want to use the value of this variable in above select statement.
how can i use this. Do not select Case_Status from inner select, so null will be inserted then after inserting it update the case status with m_caseStatus.
Regards. -
How to call subscreen and provide selection screen in subscreen
Hi experts,
please anybody suggest me how to call subscreen in module pool screen and provide selection screen in that sub screen.
please tell me how to design this subscreen in module pool screen.
adevanced
thank you
regards
vijay krishnaHi,
If you need to have select-options in module pool then follow these steps:-
To implement select-options in module pool, first design two input/output fields (textboxes) for the low and high value of the field and name it as <field_name>-low and <field_name>-high.
Create a button next the high value textbox and keep its sutaible function code.
Now, to call the pop-up on this button click, we have to call the same pop-up as in standard select-options. For this we have to use the function module COMPLEX_SELECTIONS_DIALOG.
For this FM we have to pass the table name, field name and the range for the field whose range needs to fill when using the popup screen.
To pass the table name and field name details into the FM, we have to declare as:
DATA : tab TYPE rstabfield.
This structure comprises of table name and field name.
Pass these details in program as:-
u2003
*-- clear table and field details
CLEAR tab.
*-- append for range depending on the button clicked
* either for sales order or line item
CASE sy-ucomm.
WHEN 'VBELN'.
tab-tablename = 'VBAP'.
tab-fieldname = 'VBELN'.
*--To call the popup screen for the field use code:-
CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'
EXPORTING
title = text-002 u201Ctitle text
text = ' '
signed = 'X'
search_help = v_shelp u201Csearch help if required
tab_and_field = tab u201Ctable and field name details
TABLES
range = r_vbeln u201Crange for the associated field
EXCEPTIONS
no_range_tab = 1
cancelled = 2
internal_error = 3
invalid_fieldname = 4
OTHERS = 5.
Hope this helps you.
Regards,
Tarun -
How to avoid the below nested select statement
Please any one help me how this select statemet is working and how to avoid the nesetd select statement .
if we avoid below nested , does it improve performace ?
select field1 field2
into table w_feeds
from ZTable as t
where field2 in r_feedf1
and POSITION_POSTDT =
( SELECT MAX( position_postdt ) FROM zTable
where position_postdt le r_pdate-high
and field1 = t~field1 ).
Thanks in Advace.Hi,
Instead of nested query go for two separate queries. I see you are querying on the same table...so better go by this approach
select field1 field2 POSITION_POSTDT
into table w_feeds
from ZTable
where field2 in r_feedf1.
Remove the where condition on POSITION_POSTDT
Sort the table w_feeds by POSITION_POSTDT Descending; So you will get data pertaining to Max Position_Postdt.
Finally delete the other entries which are not Max.
This will enhance the performance over the nested query.
Regards
Shiva
Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM
Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM -
How to use SET ID in select statement of SQ02
Hi,
I have a infoset, where for one of my Zfield, i have writen a select statement in order to get my ouput.
if aufk-aufnr = 'XYZ'.
select sum( FKBTR ) from fmifiit into zfmifiit
where fikrs = aufk-kokrs
and fipex IN capex
and wrttp NE '51'.
endif.
For the above statement, i have created (with 10 single values, table name FMCI, field name FIPEX) a SET id named CAPEX and used with IN operator.
But when i generating the infoset i am getting error like below
The IN operator with "CAPEX" is followed neither by an internal table nor by a value list
I was using IN opeartor for set ids during validation / substitutions, where if i have to validate multiple single values.
What to do here?
Regards,
Srinu[OPEN-SQL|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_GENERAL.htm] set of statement, [SELECT|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] statement, [WHERE|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm] addition requires a selection table (type range, [WHERE - IN seltab |http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_SELTAB.htm]) of parameter and not a set. We are in Abap here, not in a Customizing screen
You have to convert the set to a selection table in an ABAP coding before using it in a SELECT statement.
(Check FM like G_SET_TREE_IMPORT to import definition of set (values and intervals) and map them to a select-table, or ask a developper to perform it, look at G_SET_TREE_IMPORT -> select statement)
Regards,
Raymond -
How to use 'is null' in select statement of ABAP program
hi,
I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data.
SELECT * FROM mara INTO TABLE it_mara
WHERE volum IS NULL .
Can anyone resolve this.Hi PKB,
Check the below thread for NULL and Space value in ABAP . It will help you
NULL and Space value in ABAP
Regards,
Pawan -
[php+mysql] how to use variables in a select statement?
Hi all,
I'm searching for a way to use a variable in the select
statement of mysql
query.
I have this variable that can contain:
$var=field_1 field_2 field5
or
$var=field3 field4 field8
so, the variable content is not always the same.
I would like to filter a table selecting only the columns
specified by the
current $var content.
Is this possible to do something like this?
$var=field1 field5 field10
SELECT string_to_array($var)
FROM mytable
ORDER BY mysortfield ASC
Or, is there another way to select columns dynamically?
Thanks for any suggestion.
tonyHi all,
I'm searching for a way to use a variable in the select
statement of mysql
query.
I have this variable that can contain:
$var=field_1 field_2 field5
or
$var=field3 field4 field8
so, the variable content is not always the same.
I would like to filter a table selecting only the columns
specified by the
current $var content.
Is this possible to do something like this?
$var=field1 field5 field10
SELECT string_to_array($var)
FROM mytable
ORDER BY mysortfield ASC
Or, is there another way to select columns dynamically?
Thanks for any suggestion.
tony -
How to call Function Module in Selection Screen
Hi All,
I have developed one HR Report (Qualification Overview Report: To display all active employees and their Qualifications along with their Proficiency).
Already it has 3 selection fields on selection screen and now I want one more field on selection screen like Qualification Id.
But when the end user press F4 it should display the Popup which comes in TCode: PA30 at the time of Creating Qualification.
I have debugged the Standard Code and searched the Function Module: 'RH_OBJID_REQUEST' which shows Popup which I wanted to show at Selection screen for newly added field.
So I have to define new field like 'Qualification Id' and want to attach above Function Module so that it will cater my requirement.
If anybody has worked on this type of requirement then please let me know.
Thanks,
Jay.Hi Raymond,
I have written following code:
s_quali is used in selection screen for Qualification Id.
SELECT-OPTIONS : s_quali FOR hrp1000-objid NO INTERVALS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_quali-low.
CALL FUNCTION 'RH_OBJID_REQUEST'
EXPORTING
plvar = '01'
otype = 'Q'
seark = '*'
seark_begda = '18000101'
seark_endda = '99991231'
set_mode = 'X'
TABLES
sel_objects = git_objects.
LOOP AT git_objects INTO wa_objects. " Logic is to fill up the Selection screen field
s_quali-low = wa_objects-objid.
APPEND s_quali TO s_quali.
CLEAR : s_quali, wa_objects.
ENDLOOP.
Now problem is that, its not populating all values in selection screen which I select from Popup screen (Choose Qualification).
I checked that the first value in the internal Table is over written by second records in the internal table
For e.g.: If I select 001,002,003,004 from Popup screen then I am able to see only 002,003,004 in the Multiple selection view of that field though it is available in the internal table s_quali (because I am filling up the table using Loop-Endloop)
Please advise me how to overcome this issue. (How to fill up selection screen)
Thanks,
Jay.
Maybe you are looking for
-
we are seeing messages queuing up in ISH mesage queue . what is the best way to handle this situation ? should i reduce the multiplexing factor ? any experiences ?
-
Populating PDF Form with XML File.
Hi, I need my PDF form to be populated with the data in XML file.I've created a data connction to the file and binded the values to my fields.When I've opened the form in Reader/Acrobat i'm not able to see any date on the form. Currently,I'm using "x
-
Is there any event in checkBox?
Can you help me on how will I put an event in a checkBox without using JBUtton. once I put a check in checkBox, it will automatically make an event. For instance changing the label text. Can you give me a sample, what will I use. Thank you very much
-
I have checked in our Prod client and in FIBF i couldnt fine the process 00002040.However fax is sent to the Vendors.Please advice where do i check for this.Without the event how is fax is sent to the vendor.
-
What do I need to add to my comp to have two or three hdmi ports to run video or cable TV and are some better than others ?