Calling User-Defined Function in SELECT
Can I do something like:
SELECT my_func(col_1) from tab_1
SQL> CREATE OR REPLACE TYPE varchar2_pair_ot AS OBJECT
2 ( var1 VARCHAR2(1000)
3 , var2 VARCHAR2(1000) );
4 /
Type created.
SQL> CREATE OR REPLACE FUNCTION my_func
2 ( p_blah VARCHAR2 )
3 RETURN varchar2_pair_ot
4 AS
5 BEGIN
6 RETURN varchar2_pair_ot(LOWER(p_blah), UPPER(p_blah));
7 END my_func;
8 /
Function created.
SQL> CREATE TABLE blah
2 ( b1 VARCHAR2(10)
3 , b2 VARCHAR2(10) );
Table created.
SQL> CREATE TABLE xyz
2 ( abc VARCHAR2(10) );
Table created.
SQL> INSERT INTO xyz VALUES ('Blah');
1 row created.
SQL> INSERT INTO blah(b1, b2)
2 SELECT v.f.var1, v.f.var2
3 FROM ( SELECT my_func(abc) AS f
4 FROM xyz ) v;
1 row created.
SQL> SELECT * FROM blah;
B1 B2
blah BLAH
1 row selected.
Similar Messages
-
Matscript node void ouputs when calling user-defined functions
Hi,
I have a (for most of you, probably simple) problem with calling user defined function within a mathscript node.
I have a script inside a MathScript node which calls three UD functions. When I try to output variables, LabView sets their type to void, so I cannot use them further. this would imply, that the script is nondeterministic, (since the types would get set at runtime). However, if I replace the call to the UD function with the actual contents of the function, the variable becomes deterministic. Now, since I have several call to these functions, I have no desire in writing all of them many time, introducing many variables etc. What would you advise me to do?
Find attached my scripts and functions.
I need this script running on a RT Target, and have been battling this for weeks, with almost no success!
Thanks, Regards,
Luka
Attachments:
Scripts.zip 2 KBMArtin, hello!
As far as I know, LabView checks the syntax as you write in the MS Node, and since there is no X mark next to the line number, it indicates, that the syntax is correct. Since i have set the path to the UDF in both the VI options and in the general MAthScript setting, how does adding the path command help? even if I add path('directory') command, a yellow exclamation mark appears, saying the command is slowing down performance.
(this is the original help explanation:
The warning glyph indicates that LabVIEW operates with reduced error checking at edit time and slower run-time performance for the MathScript Node. The following conditions cause the warning glyph to appear. To remove the warning glyph from the MathScript Node and improve run-time performance, modify your script as follows to resolve the condition in your script:
Your script calls addpath or pathremove (legacy name rmpath), or calls cd, path, or userpath with one or more inputs, which change the MathScript search path list at run time. Remove these functions and use the MathScript page to configure the default search path)
Could you please post a screenshot of your VI, just to see, if you've got anything different set up?
I am running LV2012.
Luka -
Calling user defined function in Oracle BI Answers?
Hi
I am new in Oracle BI . I want to use the user defined function in Oracle BI Answers as a column,function written in Oracle database to calculate the Sales Revenue.
I am using Oracle BI Standard Edition One and Oracle 10g database.
Please suggest me.
Thanks
NusratSearch for EVALUATE function you can call function and pass parameters
Example:
EVALUATE Function
This function is intended for scalar and analytic
calculations.
Syntax: EVALUATE('DB_Function(%1)', {
Comma separated Expression})
Example: SELECT
e.lastname,sales.revenue,EVALUATE('dense_rank()
over(order by %1
)',sales.revenue) FROM sales s, employee e; -
Calling user defined functions through OBIEE
Can anyone tell me how I can call the user defined functions on database through the new BI tool.
The idea is to collect certain parameters through the prompt when launching the request, the function is supposed to pick up the parameters, make a certain calculation, and return a value.
I wrote the function, I just need help over how to call the function through the BI tool - that was pretty easy in the old Discoverer.
Thanks.
Message was edited by:
user611377Hi Kresimir ,
You can use EVALUATE function to call a user defined function.
EVALUATE('FUNCTIONNAME(%1,..)' As DATATYPE,parameter1,...)
Here DATATYPE is the returntype of function.
Hope this will help.
Thanks
Ashok -
Calling user defined functions in Matlab Script Node
Greetings!
I am not successful in calling a user defined function inside a Matlab Script Node.
The path has been added to Matlab, but the Matlab script node is not calling my function.
I am calling it as follows:
a= fcd(b,c);
and the fcd.m file is calculating the 'first central difference' - works in Matlab, but not in LabVIEW:
function MtxOut=fcd(MtxIn,dt)
%MtxOut=fcd(MtxIn,dt)
%first central difference method of finding instantaneous
%first derivatives
%MtxIn = MxN matrix of inputs
%dt = time change between inputs
%MtxOut = MxN matrix of first derivatives of inputs
r=size(MtxIn,1);
c=size(MtxIn,2);
MtxOut(1,=(MtxIn(2,-MtxIn(1,)/dt;
MtxOut(r,=(MtxIn(r,-MtxIn(r-1,)/dt;
for i=2:r-1
for j=1:c
MtxOut(i,j)=(MtxIn(i+1,j)-MtxIn(i-1,j))/(2*dt);
end
endMatthew:
What version of MatLab, LabVIEW are you using?. Also, what type of errors are you running into?.
Thanks,
Rudi N. -
How to call User defined functions in Mathscript Node ?
Hi,
I have created a user defined function and saved it to Search path of Labview as an M file. If I run my program in Math script window, the function is recognized and the program works properly. If I do the same with MathScript node , the user defined functions are not identified.
Kindly help me with this problem. Thanks in advance
Cheers
Lenord MelvixThis page may help:
http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmathmain/caveats_recommendations_ms_search_...
Kevin C. -
How to call User Define Function
Hi,
I need a help....
In my Project I have Login.jspx page in which there is a textbox Username.
I have second success.jspx page which has its success.java bean class in which i have define a method "display()".Now i want to cal display() in my success.jspx page.
can anyone help me out what is the way to do this.
Thanks in advance...
Thanks,
NehalHi Abhijit,
Sure i can give you more details on the same:
I have written a displayVal method in ForgotPassword.java bean class
public String displayVal() {
String txtVal = AdfFacesContext.getCurrentInstance().getPageFlowScope().get("testValue").toString();
nameID.setValue(txtVal);
return txtVal;
Now in ForgotPassword.jspx page i have one input text box named "nameID" in which i want to display some value from the user-define method called displayVal()
now i am trying to call my user-define method in my ForgotPassword.jspx page:
<af:inputText label="Name"
binding="#{backingBeanScope.backing_FrgtPwd.nameID}"
id="nameID"
value="#{backingBeanScope.backing_FrgtPwd.displayVal}">
</af:inputText>
but is is showing an error that: backingBeanScope.backing_FrgtPwd.displayVal is not a property as this a method.
So now my query is : Is there any way by which i can call my user-define method on the jspx page from the bean class of the same page. -
How to use user defined function in select query using Toplink
Hi Friends
I am little bit of new in Toplink stuff... so please help me...
I have to database functions 1. encrypt and 2. decrypt.
I want to exceute the following sql query using toplink
select port, database, user_name, decrypt(encrypt('String which is to be encrypt ','password'),'password') from CONFIGURATION
can anyone tell me , how to write code in toplink which will give the about sql output.
thanks .....The "Specifying a Custom SQL String in a DatabaseQuery" section in the TopLink Developer's Guide may help... http://download-uk.oracle.com/docs/cd/B32110_01/web.1013/b28218/qrybas.htm#BCFHDHBG
-
Calling ORACLE Store Procedure with parameters in user define function
Hi everybody,
We have a scenario connecting Oracle DB thru JDBC adapter.
We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
I am looking for an example.
Thanks in advance,
GigiI agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
If you think you are going to get existing MS Stored Procedures or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
You could use the EF backdoor, call Oracle Command object and use the Packages, if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
That's about your best shot.
http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx -
CALL USER DIFINED FUNCTION IN SQLLDR
Is is it possible to call User defined function in SQLLDR ?
COL1 COL2 COL3
1 2 06
1 2 06
1 3 06
1 4 06
2 1 06
2 1 06
I have to ignore 2nd and 6th row while loading the data . because it is duplicate records .
Is it possible in SQLLDR.If there is a unique index on the columns the duplicate rows are not loaded and sqlldr makes a *.bad-Datei (Parameter BAD=...) with the rows which are not loaded.
What should the user defined function do? -
Calling a user defined function in a select statement
PLS-00231: function 'F_GET_PROJECT_ID' may not be used in SQL
I am caling a user defined function 'F_GET_PROJECT_ID' in a select statement and getting the above error .
Can any one help me to resolve it.
I can not replace the function with a local variable nor can I assign the output of the function to a variable and use the variable in the sql stmt. cos, the in put parameters of the function comes from the same select statement.
Please help
Thanks in advanceCan you provide your function code? Using a function like that is possible from the below example. I suspect something in your function code.
SQL> create or replace function sample_func(p_sal number)
2 return number
3 is
4 v_sal number;
5 begin
6 v_sal := p_sal+100;
7 return v_sal;
8 end;
9 /
Function created.
SQL>
SQL> select empno, ename, sal, sample_func(sal)
2 from emp
3 /
EMPNO ENAME SAL SAMPLE_FUNC(SAL)
7839 KING 5000 5100
7698 BLAKE 2850 2950
7782 CLARK 2450 2550
7566 JONES 2975 3075
7654 MARTIN 1250 1350
7499 ALLEN 1600 1700
7844 TURNER 1500 1600
7900 JAMES 950 1050
7521 WARD 1250 1350
7902 FORD 3000 3100
7369 SMITH 800 900
7788 SCOTT 3000 3100
7876 ADAMS 1100 1200
7934 MILLER 1300 1400
14 rows selected.
SQL>And yeah... your formatted code is this.
cursor c1 is
SELECT t.upi_nbr upi_nbr,
f_get_project_id(l.pay_type_code,
l.charge_type_nme,
l.charge_code) project_id,
LAST_DAY(TO_DATE(SUBSTR(t.Year_Month, 5, 2)||'/'||'01'||'/'||SUBSTR(t.Year_Month,1,4),
'MM/DD/YYYY'))reporting_period_end_date,
SUM (c.hours_worked_qty) reported_hrs
from trs.trs_timesheet@oraprod5 T,
trs.trs_line@oraprod5 L,
trs.trs_cell@oraprod5 C
where T.upi_nbr=L.upi_nbr
and T.year_month=L.year_month
and L.row_nbr=C.row_nbr
and L.upi_nbr=C.upi_nbr
and L.year_month = C.year_month
and L.invalid_activity_ind = 'V'
and rtrim(L.charge_code) is not null
AND L.Pay_Type_Code<>'REQ'
and C.Hours_Worked_Qty > 0
GROUP BY t.upi_nbr,
t.year_month,
t.oui_nbr,
l.charge_code,
l.activity_detail_code,
l.charge_type_nme,
l.pay_type_code;Cheers
Sarma. -
How to add user defined functions in Menu bar of a Selection Screen?
Hi,
Can anybody please suggest me that how can I add user defined functions in the menu bar of a Selection Screen?
Regards
s@kDear Amit,
I am referring to the standard SAP program: RIEQUI20.
On the initial screen, there are 3 tabs.
Code:
SELECTION-SCREEN BEGIN OF TABBED BLOCK tab FOR 25 LINES.
SELECTION-SCREEN TAB (20) tab1 USER-COMMAND ucomm1
DEFAULT SCREEN 001.
SELECTION-SCREEN TAB (20) tab2 USER-COMMAND ucomm2
DEFAULT SCREEN 002.
SELECTION-SCREEN TAB (20) tab3 USER-COMMAND ucomm2
DEFAULT SCREEN 003.
SELECTION-SCREEN END OF BLOCK tab.
AT SELECTION-SCREEN.
CLEAR gv_okcode.
gv_okcode = sy-ucomm.
CLEAR sy-ucomm.
CASE gv_okcode.
WHEN 'IH08'.
CALL TRANSACTION 'IH08'. "Equipment Selection
WHEN 'IW29'.
CALL TRANSACTION 'IW29'. "Notification Selection
WHEN 'IW39'.
CALL TRANSACTION 'IW39'. "Order List Selection
WHEN OTHERS.
ENDCASE.
* Check date:
IF NOT datuv IS INITIAL
AND NOT datub IS INITIAL.
IF datub >= datuv.
ELSE.
MESSAGE e884(ih) WITH datuv datub.
ENDIF.
ENDIF.
IF variant IS INITIAL AND
dy_vari IS INITIAL.
PERFORM get_default_variant_f14 USING variant.
ENDIF.
PERFORM variant_existence_f14 USING variant.
IF datuv IS INITIAL.
datuv = sy-datum.
ENDIF.
IF datub IS INITIAL.
datub = sy-datum.
ENDIF.
IF sy-ucomm = 'ADDR'.
PERFORM adress_sel_f01 USING 'EQUIR'.
ENDIF.
PERFORM check_parnr_f76.
* AT SELECTION SCREEN OUTPUT
AT SELECTION-SCREEN OUTPUT.
STATICS: l_slset TYPE sy-slset.
*--- Set initial variant
PERFORM variant_init_f14 USING 'INST' 'INST' 'INST' 'RIEQUI20'.
IF variant IS INITIAL AND
dy_vari IS INITIAL AND
gv_variant_flag IS INITIAL.
PERFORM get_default_variant_f14 USING variant.
gv_variant_flag = 'X'.
ENDIF.
*--- Set Icon for adress-button
PERFORM set_icon_f01 USING dy_adrfl ad_icon text-ad0 text-ad1.
*--- get classification data from select option
*--- (if new variant or if called via submit or F3)
IF ( l_slset NE sy-slset ) OR
( s_comw[] IS NOT INITIAL AND gt_clsd_comw[] IS INITIAL ).
l_slset = sy-slset.
gv_class_old = dy_class.
gv_klart_old = dy_klart.
PERFORM copy_selopt_comw_f79 TABLES gt_clsd_comw s_comw.
PERFORM class_search_init_f77 USING 'EQUI'.
ENDIF.
*--- set Icon for classification
LOOP AT gt_clsd_comw TRANSPORTING NO FIELDS
WHERE atcod > '0'.
EXIT.
ENDLOOP.
IF sy-subrc IS INITIAL.
gv_comw_flag = 'X'.
ELSE.
CLEAR gv_comw_flag.
ENDIF.
PERFORM set_icon_f01 USING gv_comw_flag cl_icon text-cl0 text-cl1.
CALL METHOD cl_uid_cust=>selection_screen_output.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR variant.
PERFORM variant_inputhelp_f14 USING variant 'RIEQUI20'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR dy_parnr.
PERFORM f4_for_parnr_f76.
AT SELECTION-SCREEN ON BLOCK clse.
IF dy_class NE gv_class_old
OR dy_klart NE gv_klart_old.
gv_class_old = dy_class.
gv_klart_old = dy_klart.
CLEAR gv_comw_flag.
REFRESH gt_clsd_comw.
REFRESH s_comw.
ENDIF.
PERFORM class_exist_f77 USING dy_klart dy_class 'DY_CLASS'.
IF sy-ucomm = 'COMW'.
CALL FUNCTION 'IHCLSD_VALUATION_POPUP'
EXPORTING
i_klart = dy_klart
i_class = dy_class
i_language = sy-langu
i_key_date = sy-datum
i_also_subclasses = dy_subcl
TABLES
ct_comw = gt_clsd_comw
EXCEPTIONS
exc_no_class = 1
exc_klart_not_allowed = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*--- fill classification data in select option
PERFORM copy_comw_selopt_f79 TABLES gt_clsd_comw s_comw.
ENDIF.
IF sy-ucomm = 'ONLI'.
sscrfields-ucomm = sy-ucomm.
ENDIF.
Regards
s@k
Edited by: siemens.a.k on Jan 15, 2010 10:10 AM -
How to Developed user defined functions to call function modules in SAP R/3
how to Develope user defined functions to call function modules in SAP R/3 system
Hello Raja,
Go through this V.imp Link...
http://download.oracle.com/docs/cd/B10464_05/integrate.904/b10408/rfc.htm
Steps to crate FM..
Follow these steps..
Go to the T: code SE37
First You Create Function Group
On That u specify
Function Group Name..............
Short Text..............................
save...
Go to SE 37
Specify the Function Module Name: Eg: Z_Bapi_Materialmaster
Short Text.......
Save...
Next Go to Attributes..
Select Radio button : Remote enabled model
Go to Parameters..
Click Import...
Give Parameter Type Associate type S.t
next Click Export...
Give Parameter Type Associate type S.t
Next Click Tables Button..
Specify tables..
Next click source code button..
Write Source code here..
Eg : Select statements Etc..
Finally we should be select the Radio button Enable remorely
https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action?pageId=39728
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/bapi%2bstep%2bby%2bstep
Re: User Defined Functions Tutorials
Hope this information is useful to you..
Thanks ,
Satya Kumar.. -
Calling a user defined function as default value for a column
Hi All
Can we call a user defined function as default value for a column ??
for example:
create or replace function test1 return number is
begin
return 10;
end;
create table testt
(id as test1,
name varchar2(20));
getting error:
Error at line 1
ORA-02000: missing ( keywordThanks
Ashwani
Edited by: Ashwani on Jan 16, 2012 1:19 AMHi;
For your issue i suggest close your thread here as changing thread status to answered and move it to Forum Home » Database » SQL and PL/SQL which you can get more quick response
Regard
Helios -
Calling PL/SQL user defined functions from ODI Constraints
Hi All,
We are trying to call user defined PL/SQL functions from ODI. We are able to call them from ODI's User functions. But when we are trying to call them from ODI Constraints under Models, it is throwing an error 'ORA-00920 invalid relational operator'. Kindly let me know if anyone has faced the same issue and got the resolution for the same. Thanks in Advance.
Regards,
Abhishek SharmaHi Ace,
Thanks for the response, the same error was coming in operator also.
I am able to call PL?SQL user defined functions from ODI Constraints. We have to first call ODI User functions from the ODI constraints as we cant call PL/SQL function (compiled in database) directly.
From the ODI User functions, we can then call the PL/SQL functions.
Please reach out to me if you need further details reg this.
Maybe you are looking for
-
Need help please. Trying to update 10.4.11 to 10.4.8
First, looks like I have to update to 10.4.2, then 10.4.3 and so on and so on to get to 10.4.8. Can this be true? I downloaded 10.4.2 and when I tried to install I selected my HD as the destination and got a message that said "You cannot install as t
-
I have had my e 75 for about a month. Two days ago it started to continuously send and receive all the emails in the inbox. The number of emails will reduce to zero and then they all come back again then return to zero then come back on and on. th
-
Hello I am having issues with my cover art disappearing after Sync.. any ideas?
-
Experiencing Recurring Kernel Panic
So I've been experiencing recurring kernel panics for at least a month now and I seem to have narrowed down the issue to the RAM. Now I'm just not sure whether it's corrupt kernel files associated with the RAM or the actual hardware itself. I've run
-
My wife told me the other day that she was having an issue with her ipod which was happening at an increasing rate. While listening to an audio book or music it will randomly stop/freeze, and times the Ipod will reboot. Of course, when listening to a