executing a function in sql plus

喜你入骨 提交于 2019-12-03 06:38:27

问题


I created a function in oracle that inserts records in specific tables and return an output according to what occurs within the function. e.g (ins_rec return number)

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


回答1:


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

Alternatively:

select myfunc(myargs) from dual;



回答2:


One option would be:

SET SERVEROUTPUT ON

EXEC DBMS_OUTPUT.PUT_LINE(your_fn_name(your_fn_arguments));



回答3:


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;


来源:https://stackoverflow.com/questions/5127482/executing-a-function-in-sql-plus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!