Click to See Complete Forum and Search --> : Calling function in Dynamic sql


sona
11-29-2002, 01:44 AM
hi all,

using dynamic sql i want to call a function returning a number


help please

ales
11-29-2002, 02:07 AM
scott@oracle> create or replace function twice(a in number) return number
2 as
3 begin
4 return (a*2);
5 end;
6 /

Function created.

scott@oracle> declare
2 b number;
3 begin
4 execute immediate 'begin :b:=twice(7); end;' using out b;
5 dbms_output.put_line(b);
6 end;
7 /
14

PL/SQL procedure successfully completed.
See http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a77069/10_dynam.htm#13131

sona
11-29-2002, 02:23 AM
here is another one that i got after posting

declare
i number(10);
begin
execute immediate 'select twice(7) from dual' into i;
end;
/