A package to calculate your age : Utility Procedure « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE PACKAGE datecalc
  2  IS
  3     PROCEDURE showage (birthday_in IN DATE);
  4     PROCEDURE showage (birthday_in IN INTEGER);
  5     PROCEDURE showage (birthday_in IN VARCHAR2, mask_in IN VARCHAR2 := NULL);
  6  END datecalc;
  7  /

Package created.

SQL>
SQL> show error
No errors.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY datecalc
  2  IS
  3     FUNCTION datestring (date_in IN DATE) RETURN VARCHAR2 IS
  4     BEGIN
  5       RETURN 'You are ' || ROUND (TO_NUMBER (SYSDATE - date_in)) || ' days old.';
  6     END datestring;
  7
  8     PROCEDURE showage (birthday_in IN DATE) IS
  9     BEGIN
 10        DBMS_OUTPUT.PUT_LINE (datestring (birthday_in));
 11     END showage;
 12
 13     PROCEDURE showage (birthday_in IN INTEGER) IS
 14     BEGIN
 15        showage (TO_DATE (birthday_in, 'J'));
 16     END showage;
 17
 18     PROCEDURE showage (birthday_in IN VARCHAR2, mask_in IN VARCHAR2 := NULL) IS
 19     BEGIN
 20        IF mask_in IS NULL
 21        THEN
 22           showage (TO_DATE (birthday_in));
 23        ELSE
 24           showage (TO_DATE (birthday_in, mask_in));
 25        END IF;
 26     END showage;
 27  END datecalc;
 28  /

Package body created.

SQL> show error
No errors.
SQL>








27.28.Utility Procedure
27.28.1.Don't display lines longer than 80 characters
27.28.2.Create procedure for displaying long text line by line
27.28.3.Procedure create_order
27.28.4.A package to calculate your age
27.28.5.Disable trigger
27.28.6.Returns the total from an order number being passed in.
27.28.7.Dynamically perform any DDL statements from within your normal PL/SQL processing.
27.28.8.Execuate the same SQL in two ways: static way and dynamic way