Out parameter : Out Parameters « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL> CREATE  PROCEDURE changePrice (old_price NUMBER,percent_update NUMBER := 5,new_price OUT NUMBER)
  2  IS
  3  BEGIN
  4          new_price := old_price + old_price * percent_update / 100;
  5  END changePrice;
  6  /

Procedure created.

SQL>
SQL> set serveroutput on
SQL> DECLARE
  2          price_to_update NUMBER(6,2) := 20;
  3          updated_price NUMBER(6,2) := 0;
  4  BEGIN
  5          dbms_output.put_line('price before ' || price_to_update);
  6          dbms_output.put_line('updated_price before ' || updated_price);
  7          changePrice (old_price => price_to_update, new_price => updated_price);
  8          dbms_output.put_line('price_to_update after update ' || price_to_update);
  9          dbms_output.put_line('updated_price after update ' || updated_price);
 10  END;
 11  /
price before 20
updated_price before 0
price_to_update after update 20
updated_price after update 21

PL/SQL procedure successfully completed.

SQL>
SQL>








27.16.Out Parameters
27.16.1.OUT Parameters
27.16.2.Out parameter
27.16.3.Calling myProc
27.16.4.IN OUT difference