开发者

executing a function in sql plus

开发者 https://www.devze.com 2023-02-13 09:33 出处:网络
I created a function in oracle that inserts records in specific tables and return an output according to what occurs within t开发者_C百科he function. e.g (ins_rec return number)

I created a function in oracle that inserts records in specific tables and return an output according to what occurs within t开发者_C百科he function. e.g (ins_rec return number)

How do I call this function and see its output in sql plus


declare
  x number;
begin
  x := myfunc(myargs);
end;

Alternatively:

select myfunc(myargs) from dual;


One option would be:

SET SERVEROUTPUT ON

EXEC DBMS_OUTPUT.PUT_LINE(your_fn_name(your_fn_arguments));


As another answer already said, call select myfunc(:y) from dual; , but you might find declaring and setting a variable in sqlplus a little tricky:

sql> var y number

sql> begin
  2  select 7 into :y from dual;
  3  end;
  4  /

PL/SQL procedure successfully completed.

sql> print :y

         Y
----------
         7

sql> select myfunc(:y) from dual;
0

精彩评论

暂无评论...
验证码 换一张
取 消