Package with only one function : Package Body « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> CREATE OR REPLACE PACKAGE valerr
  2  IS
  3     FUNCTION get RETURN VARCHAR2;
  4  END valerr;
  5  /

Package created.

SQL>
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY valerr
  2  IS
  3     v VARCHAR2(1) := 'ABC';
  4
  5     FUNCTION get RETURN VARCHAR2
  6     IS
  7     BEGIN
  8        RETURN v;
  9     END;
 10  BEGIN
 11     DBMS_OUTPUT.PUT_LINE ('Before I show you v...');
 12
 13  EXCEPTION
 14    WHEN OTHERS
 15    THEN
 16      DBMS_OUTPUT.PUT_LINE ('Trapped the error!');
 17
 18  END valerr;
 19  /

Package body created.

SQL>
SQL>








27.11.Package Body
27.11.1.Package with only one function
27.11.2.Package with two procedures
27.11.3.Package declaration and body
27.11.4.Use of 'get' and 'set' prefixes
27.11.5.Use package method in a procedure
27.11.6.Call function in a Package
27.11.7.Method overload
27.11.8.Package method overloading
27.11.9.Reference method from another package
27.11.10.Package Function with 'PRAGMA AUTONOMOUS_TRANSACTION'
27.11.11.Create a package containing stored procedure DELETE_ORDERS and stored function GET_employee_NAME.
27.11.12.Package initialization.
27.11.13.Use package member variable to pass value