Call function and store the return value to a variable : Function Call « Stored Procedure Function « Oracle PL / SQL






Call function and store the return value to a variable

 
SQL>
SQL>
SQL> create or replace function first_function return varchar2 as
  2  begin
  3    return 'Hello World';
  4  end first_function;
  5  /

Function created.

SQL>
SQL>
SQL>
SQL> set serverout on
SQL>
SQL> declare
  2    l_str varchar2(100) := null;
  3  begin
  4    l_str := first_function;
  5    dbms_output.put_line( l_str );
  6  end;
  7  /
Hello World

PL/SQL procedure successfully completed.

SQL>

 








Related examples in the same category

1.Call function in dbms_output.put_line
2.Use a user-defined function in stored procedure
3.Local Subprograms
4.Calling a Function
5.This function cannot be called from a SQL statement: cannot perform a DML operation inside a query
6.This function can be called from a SQL statement.
7.Function with insert statement can be called from a DML statement.