Save the returning value from a procedure to a variable : Function Return « Stored Procedure Function « Oracle PL / SQL






Save the returning value from a procedure to a variable

    
SQL>
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> VARIABLE v_Output VARCHAR2(50);
SQL> CALL CallFunc('Hello!') INTO :v_Output;
CallFunc called with Hello!

Call completed.

SQL> PRINT v_Output

V_OUTPUT
--------------------------------------------------------------------------------
Hello!

SQL>
SQL>

   
    
    
  








Related examples in the same category

1.Return varchar2 value from function
2.Function return Integer
3.Return value from a function
4.Use function return value in select statement
5.RETURN statement.
6.Multiple RETURN Statements
7.Return a type
8.Concatenates two strings into one:
9.Return a varray from a function
10.Append result from generator function to a table
11.We use user function in DML statements
12.This script demonstrates using a record type as a function return value
13.Use function to check passwords
14.Use user-defined function to combine and format columns