Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic call to function ?
On Wed, 3 Dec 1997 20:54:12 +0100, "Magnus Rosenquist" <maro_at_gbg.ifsab.se> wrote:
>Hi !
>
>Is there anybody who knows if it's possible to dynamically
>call a function and receive the correct return value
>from it ?
>
>I've tried a bit but not managed to get to work,
>this is how I've done:
>
You've missed one line of code, I've added it below.
In pl/sql we don't have pointers. When you bind, you aren't binding like you are in OCI/Pro*c. You must 'bind' to input and 'unbind' to output. The bind_variable call sets the input value, the variable_value gets the changed result back...
>set serverout on size 10000
>declare
> procedure_ varchar2(200):='TEST_PKG.test';
> statement_ varchar2(1000);
> C integer;
> count_ integer;
> return_code_ number:=0;
>begin
> statement_ := 'BEGIN :rcode_ := '||procedure_||'; END;';
> C := dbms_sql.open_cursor;
> dbms_sql.parse( C, statement_, dbms_sql.native );
> dbms_sql.bind_variable(C, 'rcode_', return_code_);
> count_ := dbms_sql.execute( C );
dbms_sql.variable_value(C,'rcode_', return_code_ );
> dbms_sql.close_cursor( C );
> dbms_output.put_line('return_code: '||return_code_);
>end;
>/
>
>The function TEST_PKG.test returns the number 1, but the
>response from dbms_output is the number 0.
>
>Is it possible to do this ?
>
>regards,
>// Magnus
>
>Magnus Rosenquist
>IFS Sweden AB
>
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Dec 03 1997 - 00:00:00 CST