How can I call the pl / sql stored procedure (function that returns a numeric value)?

I am using Oracle SQL developer or Oracle SQL * Plus

+7
sql oracle plsql oracle-sqldeveloper sqlplus
source share
2 answers

In SQL Plus, you can do this:

var x number exec :x := myfunction(); 

Or you can use SQL:

 select myfunction() from dual; 
+16
source share

The above example shows how to call a function from SQL * Plus. If you are calling a function from a PL / SQL procedure, see the example below.

 DECLARE x NUMBER; BEGIN x := myfunction(); END; 

A more complex example that returns 100 (10 * 10):

 DECLARE x NUMBER; FUNCTION mysquare(in_y IN NUMBER) RETURN NUMBER IS BEGIN RETURN in_y * in_y; END mysquare; BEGIN dbms_output.enable; x := mysquare(10); dbms_output.put_line(x); END; 
+2
source share

All Articles