How can we call a function from an anonyms block?

Showing Answers 1 - 2 of 2 Answers

hi,

suppose a function  add two number and you desire to call it from anonyms block.

create or replace function f_add(a in number,b in number) return number as

c number;

begin

c:= a+b;

return (c);

end;

to see output

sql> variable x number;

sql> begin

    :x := f_add(2,2);

   end;

sql> /

sql> print x

  Was this answer useful?  Yes

We can call a function from anonymous block as a part of sql statement written in that block.eg: create or replace function fn_emp(v_empno in number)return varchar2 isbeginselect ename into v_ename from empwhere empno=v_empno;return v_ename;end;this function we can use in sql statement like followsselect fn_emp(101) from emp;it can also be assigned to a variable like thisv_value:=fn_emp(101);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions