EXECUTE IMMEDIATE dynamic statement and return value
SQL>
SQL> CREATE OR REPLACE FUNCTION CallFunc(p1 IN VARCHAR2)
2 RETURN VARCHAR2 AS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('CallFunc called with ' || p1);
5 RETURN p1;
6 END CallFunc;
7 /
Function created.
SQL>
SQL> DECLARE
2 myResult VARCHAR2(50);
3 BEGIN
4 EXECUTE IMMEDIATE
5 'CALL CallFunc(''Hello from PL/SQL'') INTO :myResult'
6 USING OUT myResult;
7 END;
8 /
CallFunc called with Hello from PL/SQL
PL/SQL procedure successfully completed.
SQL>
SQL>
Related examples in the same category