Index | Home | Forums
Oracle PL/SQL Example B-2 Using the Dot Notation to Qualify Names

Example B-2 Using the Dot Notation to Qualify Names

CREATE OR REPLACE PACKAGE pkg1 AS
   m NUMBER;
   TYPE t1 IS RECORD (a NUMBER);
   v1 t1;
   TYPE t2 IS TABLE OF t1 INDEX BY PLS_INTEGER;
   v2 t2; 
   FUNCTION f1 (p1 NUMBER) RETURN t1;
   FUNCTION f2 (q1 NUMBER) RETURN t2;
END pkg1;
/

CREATE OR REPLACE PACKAGE BODY pkg1 AS
   FUNCTION f1 (p1 NUMBER) RETURN t1 IS
      n NUMBER;
   BEGIN
-- (1) unqualified name
      n := m;
-- (2) dot-separated chain of identifiers (package name used as scope
--  qualifier followed by variable name)
      n := pkg1.m;
-- (3) dot-separated chain of identifiers (package name used as scope
--  qualifier followed by function name also used as scope qualifier
--  followed by parameter name)
      n := pkg1.f1.p1;
-- (4) dot-separated chain of identifiers (variable name followed by
--  component selector)
      n := v1.a;
-- (5) dot-separated chain of identifiers (package name used as scope
--  qualifier followed by variable name followed by component selector)
      n := pkg1.v1.a;
-- (6) indexed name followed by component selector
      n := v2(10).a;
-- (7) function call followed by component selector
      n := f1(10).a;
-- (8) function call followed by indexing followed by component selector
      n := f2(10)(10).a;
-- (9) function call (which is a dot-separated chain of identifiers,
-- including schema name used as scope qualifier followed by package
-- name used as scope qualifier followed by function name)
-- followed by component selector of the returned result followed
-- by indexing followed by component selector
      n := hr.pkg1.f2(10)(10).a;
-- (10) variable name followed by component selector
      v1.a := p1;
     RETURN v1;
   END f1;

   FUNCTION f2 (q1 NUMBER) RETURN t2 IS
   v_t1 t1;
   v_t2 t2;
   BEGIN
     v_t1.a := q1;
     v_t2(1) := v_t1;
     RETURN v_t2;
   END f2; 
END pkg1;
/



This page was generated on/at Feb 23,2008 00:20:12
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here




Index | Home | Forums
Oracle PL/SQL Example B-2 Using the Dot Notation to Qualify Names

Example B-2 Using the Dot Notation to Qualify Names

CREATE OR REPLACE PACKAGE pkg1 AS
   m NUMBER;
   TYPE t1 IS RECORD (a NUMBER);
   v1 t1;
   TYPE t2 IS TABLE OF t1 INDEX BY PLS_INTEGER;
   v2 t2; 
   FUNCTION f1 (p1 NUMBER) RETURN t1;
   FUNCTION f2 (q1 NUMBER) RETURN t2;
END pkg1;
/

CREATE OR REPLACE PACKAGE BODY pkg1 AS
   FUNCTION f1 (p1 NUMBER) RETURN t1 IS
      n NUMBER;
   BEGIN
-- (1) unqualified name
      n := m;
-- (2) dot-separated chain of identifiers (package name used as scope
--  qualifier followed by variable name)
      n := pkg1.m;
-- (3) dot-separated chain of identifiers (package name used as scope
--  qualifier followed by function name also used as scope qualifier
--  followed by parameter name)
      n := pkg1.f1.p1;
-- (4) dot-separated chain of identifiers (variable name followed by
--  component selector)
      n := v1.a;
-- (5) dot-separated chain of identifiers (package name used as scope
--  qualifier followed by variable name followed by component selector)
      n := pkg1.v1.a;
-- (6) indexed name followed by component selector
      n := v2(10).a;
-- (7) function call followed by component selector
      n := f1(10).a;
-- (8) function call followed by indexing followed by component selector
      n := f2(10)(10).a;
-- (9) function call (which is a dot-separated chain of identifiers,
-- including schema name used as scope qualifier followed by package
-- name used as scope qualifier followed by function name)
-- followed by component selector of the returned result followed
-- by indexing followed by component selector
      n := hr.pkg1.f2(10)(10).a;
-- (10) variable name followed by component selector
      v1.a := p1;
     RETURN v1;
   END f1;

   FUNCTION f2 (q1 NUMBER) RETURN t2 IS
   v_t1 t1;
   v_t2 t2;
   BEGIN
     v_t1.a := q1;
     v_t2(1) := v_t1;
     RETURN v_t2;
   END f2; 
END pkg1;
/



This page was created by oracleabc.com on Feb 23,2008 00:09:02
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here