How to perform a function with parameter date as input?
HelloI have a function named fun1 (v_fun in date), including the date as an input parameter, and it returns a number. I created the function successfully. But I couldn't run this function in sqlplus. How to move the dates? Can someone help me in this regard.
Hello
V11081985 wrote:
Hello
I have a function named fun1 (v_fun in date), including the date as an input parameter, and it returns a number. I created the function successfully. But I couldn't run this function in sqlplus.
It is difficult for me to say what you're doing wrong when I don't know what you're doing. After a full test script that people can run to recreate the problem and test their ideas. Include a definition of function, CREATE TABLE and INSERT statements for one of your own tables (if necessary) and the results you want from this data, as well as your query.
How to move the dates? Can someone help me in this regard.
You can call the function like this:
SELECT fun1 (hiredate) AS fun1_results
FROM scott.emp
;
Tags: Database
Similar Questions
-
How to perform a function with out parameter dynamically?
I have a function:
FUNCTION to CREATE or REPLACE testdyn1 (in_1 NUMBER, OUT out_1)
RETURN VARCHAR2 IS
BEGIN
out_1: = in_1 + to_number (to_char (SYSDATE, 'ss'));
RETURN ' Ok! ' || TO_CHAR (SYSDATE, 'ss');
END;
How to call it dynamically? I did this:declare
number of v_in: = 3;
number of v_out;
v_ret varchar2 (100);
v_st varchar2 (4000);
Start
v_st: = ' START: v_ret: = testdyn1 (: v_in,: v_out); END;';
EXECUTE IMMEDIATE v_st USING v_in, OUT v_out, v_ret;
dbms_output.put_line ('v_out =' | v_out |) ' / ' || 'v_ret =' | v_ret);
end;
I get the error:
ORA-06536: IN bind variable end to a position
ORA-06512: at line 8 level
BluShadow wrote:
My question would be why on Earth, you call a function dynamically?
Dynamic SQL is bad enough... but dynamic PL/SQL is just a matter of trouble.
If an application is designed properly so you know the name of the function and the parameters passed, while there should be no reason to call it dynamically.
Whenever someone starts mentioning the dynamic code, the first thing that you should always say is "Stop!" What are you trying to do? "and look at why you eventually go that route.
Good point. But the problem is the client (which is our customer) is instructing us to do. So we can't complain.
Finally, I was able to do.
Here is the code:
FUNCTION to CREATE or REPLACE testdyn1 (in_1 NUMBER, out_1 OUT VARCHAR2)
IS BACK PLS_INTEGER
BEGIN
out_1: = to_char (to_number (in_1) + to_number (to_char (SYSDATE, 'ss')));
RETURN in_1 | TO_NUMBER (to_char (SYSDATE, 'ss'));
END;
____________________________________
declare
v_ret_val pls_integer;
v_out varchar2 (1000);
v_stmt varchar2 (4000);
number of v_in: = 1;
Start
v_stmt: = ' START: 1: = testdyn1 (: 2: 3); END;';
EXECUTE IMMEDIATE v_stmt help to v_ret_val into v_in, at v_out;
dbms_output.put_line(v_ret_val ||) ' / ' || v_out);
end;
126 / 27
PL/SQL procedure successfully completed
-
perform an immediate function with parameter out
How to perform a function with parameter in the statement immediately execute?
error: ORA-06572 startfunction function has argumentsdeclare vRunFunctie varchar2(100) := 'startfunction'; vParmIn1 varchar2(100) := 'AAA'; vParmIn2 varchar2(100) := 'HHH'; vParmOut1 number; vParmOut2 varchar2(100); begin -- execute immediate 'select '||vRunFunctie||'('''||vParmIn1||''','''||vParmIn2||''',:vParmOut2) from dual' into vParmOut1 using vParmOut2; -- dbms_output.put_line('vParmOut1['||vParmOut1||']'); dbms_output.put_line('vParmOut2['||vParmOut2||']'); end; /
the statement looks like this in pl/sql:
Thank you.vParmOut1 := startfunction(vParmIn1, vParmIn2, vParmOut2); --vParmOut1 := startfunction('AAA', 'HHH', vParmOut2);
L.
Update:
I know that the function should not have out parameters. But its programmed that way already...You are not using bind variables with your dynamic code. That is a major mistake and the #1 reason for poor database performance. It is a fundamental flaw in programming to design a function that includes output parameters. This is simply and plainly wrong. Output parameters are also not supported by the SQL language - it does not support "procedure" like code units and call methods.
You try something like
declare vRunFunctie varchar2(100) := 'startfunction'; vParmIn1 varchar2(100) := 'AAA'; vParmIn2 varchar2(100) := 'HHH'; vParmOut1 number; vParmOut2 varchar2(100); begin -- execute immediate 'begin :x := ' || vRunFunctie || '( :p1, :p2, :vParmOut2 ); end;' using out vParmOut1, vParmIn1, vParmIn2, out vParmOut2; -- dbms_output.put_line('vParmOut1['||vParmOut1||']'); dbms_output.put_line('vParmOut2['||vParmOut2||']'); end; /
-
How can I call a function with parameter out of sql
Hello world
I'm calling a Sql statement function and I get this error ORA-06572: XX function has arguments.
can you offer any solution on this workaround.
Thank youHello
Sorry, you cannot call functions with OUT arguments (or arguments, but I'll just say in the future) SQL statements.
This is one of the reasons why many people avoid having arguments in functions.
THE arguments are never optional. If the function expected of them, you must pass to them.Depending on your needs, you can write a Wrapper function that has no arguments.
For example, if you want to call this function:fun1 ( in_out_str IN OUT VARCHAR2 , in_num IN NUMBER ) RETURN NUMBER ...
you don't need really the value changed to in_out_str, then you can write a function like this:
fun1_wrapper ( in_str IN VARCHAR2 , in_num IN NUMBER ) RETURN NUMBER IS in_str2 VARCHAR2 (32767) := in_str; BEGIN RETURN fun1 ( in_str2 , in_num ); END fun1_wrapper;
You can use fun1_wrapper in a SQL statement, even if you cannot use fun1 in the same statement.
Published by: Frank Kulash on February 27, 2013 09:42
-
How to call the function with arguments varray.
Hello
I've got function like this:
How can I build this function call (nvarchar data type is necessary) using the only pl/sql and can do with pure as sql select double f();?CREATE OR REPLACE TYPE VARR_VARCHAR AS VARRAY(256) OF NVARCHAR2(500) / CREATE OR REPLACE TYPE E_VARR_VARCHAR AS VARRAY(256) OF nVARCHAR2(4096) / FUNCTION find_id( p_id IN VARCHAR2, p_special_columns IN varr_varchar, p_special_values IN e_varr_varchar, ) RETURN VARCHAR2;
I'm on 9.2.0.8.
Concerning
GregGSelect find_id (p_id, VARR_VARCHAR('1','2','3'), e_varr_varchar('1','2','3')) of double;
-sty.
-
How to handle a function with struct return of dll?
I have a dll 'SCTSCTL_OPEN' function returns a structure like
typedef struct _sctsctl_t {}
HANDLE hDevice;
unsigned char ctl [2];
unsigned long necessarily;
unsigned long data_diff;
HANDLE IsrThread;
HANDLE IsrEventHandle;
PVOID can't;
void (* Manager) (struct _sctsctl_t * board, int intvec);
} * sctsctl_t;SCTS_API sctsctl_t __stdcall SCTSCTL_OPEN (DWORD instance);
I have imported this dll with LabVIEW and vi returns an unsigned long integer shown as follows.
How to make a comeback with structure? Any help would be appreicated.
Kind regards
Adam
LV 8.5.1
Normally I would be tempted to do a wrapper function and call it with LV LV. handles structure not so naturally.
-
How to perform a function and return the result in a variable of liaison
Hello
I'm trying to calculate the sum of the salaries of all persons with a particular using a function JOB_ID TOTAL_INCOME (v_job_id).
create or replace function total_income
+ (v_job_id in VARCHAR2) +.
Number IS BACK
v_total number (6);
cursor get_sal is
Select the pay of employees
where job_id = v_job_id;
BEGIN
v_total: = 0;
for emp in get_sal
loop
v_total: = v_total emp.salary; +.
end loop;
dbms_output.put_line (' Total salary ' | v_job_id |' is: ' | v_total);
Return v_total;
END;
Now I woud like to perform this function and assign the value returned in a variable binding test_sal
test_sal variable number (6)
SELECT total_income ('AD_VP') in: test_sal FROM DUAL;
dbms_output.put_line (' Sal Total :'||: test_sal);
This returns the errors below:
SELECT total_income ('AD_VP') in: test_sal FROM DUAL
*+
Error on line 0
ORA-01036: illegal variable name/number
dbms_output.put_line (' Sal Total :'||: test_sal);
Error on line 3
ORA-00900: invalid SQL statement
Could someone help me what could be the problem? Thanks for your time...Hi Kiran and welcome to the forum,
You mix SQL and PL/SQL
It's the way in which SQL:
SQL> SELECT total_income('AD_VP') FROM DUAL; TOTAL_INCOME('AD_VP') --------------------- 123 1 row selected.
It comes to PL/SQL in SQL * more
SQL> variable test_sal number SQL> execute :test_sal := total_income('AD_VP') PL/SQL procedure successfully completed. SQL> exec dbms_output.put_line('Total Sal:'||:test_sal) Total Sal:123 PL/SQL procedure successfully completed
Concerning
Peter -
performs a function with one parent at the end of a child.swf
question: how to call a function which is within a parent.swf of a child external swf (Loader class)?
In my menu.swf, there is a child (Loader class) of a content.swf that is loaded below on the race. Then when a button is clicked, it returns a string that contains the name of the content file to load then, then launches a final function on the child who made an outro animation.
function buttonClick(event:MouseEvent):void
{
nextContent = event.target.name + ".swf";
MovieClip (newContent.contentLoaderInfo.content) .endSequence ();
}
------------------------------------------
After the final sequence has performed in the ccontent.swf I need to know how to make a call to a function in the menu.swf so that I can load the nextContentMovieClip (parent.parent) work, then?
-
How 2 call a procedure with the data type for the parameter Ftree.NODE
Hello
in this link
http://Andreas.Weiden.ORCL.over-blog.de/article-29307730.html
Down in the page after you run the package, I created the procedure and it compiled successfully but when call PR_WTNS in trigger WHEN-TREE-NŒUD-SELECTED
PROCEDURE PR_WTNE (i_ndNode IN Ftree.NODE);
as
PR_WTNE (i_ndNode Ftree.NODE);
I got the error message; A wrong number or types of argument in the call
pls I'm stuck can help any one?
Kind regards
Abdetu...
Published by: Abdetu on October 24, 2010 02:36
Published by: Abdetu on October 24, 2010 02:36YKou have to give a variable of type Ftree.NODE when calling this function. If called fromm a WHEN-TREE-NODE-SELECTED-trigger, use: SYSTEM. TRIGGER_NODE
-
How to associate cluster esx with the data report store
Hi all
I'm running a repore that displays data stores less than 50 free concerts. The storage team would like a coloum for esx clusters associated with the LUN. I can't see to find it and what is possible.
Thanks in advance,
Scott.
I would create a WCF function, script type, with a timeRange parameter and a new data store VMWDatastore context parameter, required, not a list. Set the output in common: string.
Add the following script:
QS = server. QueryService
Query = "!" "VMWCluster where esxServers.datastores.uniqueId = ' ${datastore.uniqueId}"
cluster = server. QueryService.queryTopologyObjects (query)
clusterNames = clusters? collect {cluster-> cluster?. name}?. Join(', ')
return clusterNames
You can then use this in your report, feeding the entrance of context for the current row data store.
-
How to fill the DataGird with the data returned by the php page?
Hi, I'm new to Flex, I try to fill DataGrid with data from PHP, my code is
< mx:HTTPService
id=" personRequest = URL "result ="getPerson (event)" http://localhost/searchPerson.php " useProxy = ' fake "method =" " POST "
showBusyCursor ="
true "resultFormat =" " E4X " >
< /.
MX:HTTPService >
< mx:DataGrid
id=" searchResult " " dataProvider =" {? what to paste here? } }" y="30"
>
< / mx:DataGrid >
.....
private
function getPerson(evt:ResultEvent):Sub { }
var res: XMLList = evt.result... Dane as XMLList;
search results =
new (Res) XMLListCollection;
}
....
output of PHP
< person >
< dane >
< name > CBA < / name >
< Street > XLXXLX < / street >
< / dane >
< dane >
< name > DEF < / name >
< Street > CIWU < / street >
< / dane >
< / person >
If I set the dataProvider as search results "" it doesn't work. I have probably set all collection ArrayCollection as a dataprovider, but I don't know how to convert my XMLListCollection for her.
Could someone help me complete Datagrid with
name | Streer
ABC, XLXXLX
DEF, CIWU
Best regards
Mariusz
After the datagrid control, you post the above code.
-
How to call a procedure with parameter SYS_REFCURSOR OUT
Hello
With the help of Oracle 11 g R2.
I would like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor) as begin open result for select 1 from dual union all select 2 from dual; end;
I want to call this procedure similar to how a query is called and executed. Like this
Select * from testprocedure
I have seen lots of examples on the web that show how it is possible to loop through the results of a sys_refcursor inside an anonymous block and display the results using dbms_output.putline, but this isn't the method I'm looking for.
Read this: PL/SQL 101: understanding Ref Cursor
You're wrong if you think a ref cursor is a result set of data that you can query from.
-
Performance of BI with warehouse data or data warehouse.
Hi gurus,
Anyone here have a document or presentation to compare a BI performance which is implemented with the warehouse database or data warehouse?
Appreciate your help :)You need to come to a conclusion of performance tests.
The query can also have different points of view;
1 compare the performance on obtaining data directly from the source systems against obtaining data accumulated in a single database.
2. by comparing the performance on obtaining data from a standard model against data from a dimensional model.In most cases; getting data from data warehouses should give better performance since then.
Data warehouses allocate more resources toward BI systems.
Source systems serve much purpose other than BI systems; If resources are shared.
In a data warehouse for data sets are already in the same place, reducing the latency of the network.
Data warehouse stores summary information.
Data warehouses are implemented with three-dimensional models which serves best for the BI queries. -
How to do a function with the same argument multiple times and return values in the variables?
The problem I have is that I have created a function that is really kind of database. Basically, a bunch of:
If (a.value == 'number') {}
b.value = "this expression."
}
Inside of the shape are 2 drop-down lists that return numeric values I want to process through this function and the value of return inside separate variables.
var a = this.getField ("OPE003. EVEN.1.MIP");
MIP (a);
var Result1 = Mip();
I tried to smash * a * to treat the second field
a = this.getField ("OPE003. EVEN.2.MIP");
MIP (a);
var Result2 = Mip();
Result1 and result2 are placed in an array, joined as a string.
In doing so, I always get the last treatment twice more than the final result.
Can I use a function as a batch processor that way?
You're right, I changed the code to what you said, but how to pass another value by my function so I can get Result1 and Result2?
is it
var a = this.getField ("OPE003. EVEN.1.MIP");
var b = this.getField ("OPE003. EVEN.2.MIP");
Result1 var = Mip (a);
var Result2 = Mip (b);
var c = new Array [performance(1), result2]
-
Oracle is how to change the functionality of a data entry form.
Hi guys,.
I'd like know if theres a way to retrieve and enter records in a form that is based on a single table, with this kind of functionality:
-Enter the primary key (enter or tab), if the record exists then poster for edit and register.
-If this is not the case exists, and then accept data in the fields and then save.
This is because recently a customer migrate a small application of advanced forms of oracle revelation, and the people who use this registration form complains because they say that you need to type more keys to retrieve information.
I know what it means to ignore the native functions to a form of oracle, but it's a question that I was invited.
I apologize for my English.
JorgeGood afternoon Jorge.
Yes, you can do what you described. You can use a trigger when-validate-item to search for the key value the user has entered and then, if found, complete the rest of the screen. If the value is NOT found, you can just go to the next input value to allow the user to continue to enter the folder.
Good luck
Don.AWARDS: Don't forget to mark correct or useful posts on the forum, not only for my answers, but for everyone! :)
Maybe you are looking for
-
I have a late 2012 27 "iMac with OX10.95 Intel core i7 to 3.4 ghz For the last two months it has been mainly crashing when using photoshop CS5 and today that it crashed when I don't have photoshop open and just clicked on the Apple logo at the top ri
-
Wireless not working not not on portable Satellite
I bought my laptop in November and were much used but last night my wireless completely disappeared when I was on the laptop. It's now only send me options to connect to the Ethernet cable. I tried to restart the PC but the problem persists, I also t
-
Problem with the Lenovo Z510 battery indicator
I have an old Ideapad of one year z510. Last week, the battery indicator began to stuck on 100%. So not connected, he stops suddenly without notifying me with 10% and 7% remaining notification. I tried to uninstall the Microsoft ACPI control method b
-
Can you please help and tell me how to fix it?
I don't know what kind of problem I'm having with the registry editor, but at first until I met the same I have a top of lop with windows vista and whenever I start my pc it opens a window of the Registry Editor (3 of them exactly) and it's a kind of
-
Host USB 3 controller not found
I use win 7 Home Edition desktop samsung laptop core i7. This laptop has 4 usb ports including 2 of them have stopped working and I get this message 3 host controller: usb not found