Example for procedures with INOUT parameters in Oracle, PL/SQL

Bhanu V picture Bhanu V · Nov 10, 2010 · Viewed 36.3k times · Source

How can I use IN OUT parameter in a procedure. I want to give a parameter as both input and get the same out put? can i have an example for this?

Answer

Tony Andrews picture Tony Andrews · Nov 10, 2010

Do this in SQL Plus:

set serverout on

declare
  l_val varchar2(30) := 'hello world';
  procedure myproc (p_val in out varchar2) is
  begin
    dbms_output.put_line('p_val was ' || p_val);
    p_val := 'something else';
  end;
begin
   myproc(l_val);
   dbms_output.put_line('l_val is now ' || l_val);
end;
/

You should see the output:

p_val was hello world
l_val is now something else