Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to run a function with out parameter dynamically?

user12240205Mar 3 2014 — edited Mar 4 2014

I have a function:

CREATE OR REPLACE FUNCTION testdyn1(in_1 NUMBER, out_1 OUT NUMBER)

   RETURN VARCHAR2 IS

BEGIN

   out_1 := in_1 + to_number(to_char(SYSDATE, 'ss'));

   RETURN 'Ok! ' || to_char(SYSDATE, 'ss');

END;


How to call this dynamically? I did this:

declare

    v_in number := 3;

    v_out number;

    v_ret varchar2(100);

    v_st varchar2(4000);

  begin 

     v_st := 'BEGIN :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 error:

ORA-06536: IN bind variable bout to an OUT position

ORA-06512: at line 8

This post has been answered by user12240205 on Mar 4 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2014
Added on Mar 3 2014
10 comments
585 views