EXECUTE IMMEDIATE dynamic statement and return value : Call « Stored Procedure Function « Oracle PL / SQL






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

1.CALL statement.
2.demonstrates using DBMS_SQL to execute CALL statement.
3.illegal procedure call
4.Using call statement in a dynamic statement is legal
5.This script demonstrates the use of the CALL statement.