Tuesday 7 August 2012

How to Use In and Out operator in procedures of Oracle


This a Procedure Example

create or replace procedure PrintEmpInfo(empno in employeeTest.eno%type, v_name out employeeTest.ename%type, v_salary  out employeeTest.esalary%type)
is
begin
Select  ename,esalary  into  v_name, v_salary
from employeetest
where eno= empno;
end printEmpInfo;

NOTE:-  we send the employee no from the calling environment to the procedure and in procedure  the select statement  feed in the  variable v_name,v_salary using into  with  the select and return it the calling environment back to procedure call.


This is a calling Environment either sql Command Window or  Test window in plsql developer
declare
  -- Local variables here
  b varchar2(50);
  c number;
begin
  -- Test statements here
  printempinfo(101,b,c);
  dbms_output.put_line(b);
  dbms_output.put_line(c);
end;

No comments:

Post a Comment