Oracle PL/SQL - IN OUT parameters

Introduction

You can use IN OUT parameters for both input to and output from the sub-program.

If the actual parameter already had some value, the formal parameter is initialized with that value:

Demo

SQL>
SQL> declare-- from  w ww.j av a2 s  . c  o  m
  2    v_hour_nr NUMBER:=12;
  3    v_min_nr  NUMBER:=20;
  4    procedure p_split (i_date_dt DATE,
  5       o_hour_nr IN OUT NUMBER, o_min_nr IN OUT NUMBER)
  6    is
  7    begin
  8      DBMS_OUTPUT.put_line(o_hour_nr||'/'||o_min_nr);
  9      o_hour_nr:=to_NUMBER(to_char(i_date_dt,'hh24'));
 10      o_min_nr :=to_char(i_date_dt,'mi');
 11      DBMS_OUTPUT.put_line(o_hour_nr||'/'||o_min_nr);
 12    end;
 13  begin
 14      p_split(sysdate, v_hour_nr, v_min_nr);
 15      DBMS_OUTPUT.put_line ('Total minutes:'||(v_hour_nr*60+v_min_nr));
 16  end;
 17  /
12/20
16/42
Total minutes:1002

PL/SQL procedure successfully completed.

SQL>