IN OUT parameters : IN OUT Parameters « Function Procedure Packages « Oracle PL/SQL Tutorial






You can use IN OUT parameters for both input to and output from the subprogram.

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

SQL> create or replace procedure p_split (i_date_dt DATE,
  2       o_hour IN OUT NUMBER, o_min IN OUT NUMBER)
  3  is
  4  begin
  5      DBMS_OUTPUT.put_line(o_hour||'/'||o_min);
  6      o_hour:=to_NUMBER(to_char(i_date_dt,'hh24'));
  7      o_min :=to_char(i_date_dt,'mi');
  8      DBMS_OUTPUT.put_line(o_hour||'/'||o_min);
  9  end;
 10  /

Procedure created.

SQL>
SQL>
SQL> declare
  2    v_hour NUMBER:=12;
  3    v_min  NUMBER:=20;
  4  begin
  5      p_split(sysdate, v_hour, v_min);
  6      DBMS_OUTPUT.put_line (
  7         'Total minutes:'||(v_hour*60+v_min));
  8  end;
  9  /
12/20
21/27
Total minutes:1287

PL/SQL procedure successfully completed.

SQL>








27.17.IN OUT Parameters
27.17.1.IN OUT parameters
27.17.2.Demonstrate the behavior of IN, OUT, and IN OUT parameter modes.