Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL EXTEND      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: EXTEND

Definition:
EXTEND is one of the Oracle PL/SQL collection methods which is used with nested tables and VARRAYS to append single or multiple elements to the collection. Note that EXTEND cannot be used with associative arrays. EXTEND has three forms:

  1. EXTEND, which adds a single NULL instance.
  2. EXTEND(n) which adds multiple NULL instances. The number of instances is specified by n.
  3. EXTEND(n,m) which appends n copies of instance m to the collection.

Note that forms one and two cannot be used for NOT NULL specified collections.

Example Usage:

The PL/SQL block below declares a PL/SQL table collection and appends the first cell at the end of the collection.

DECLARE
TYPE PSOUG_TAB IS TABLE OF NUMBER;
PTAB PSOUG_TAB;
BEGIN
PTAB := PSOUG_TAB();
PTAB.EXTEND;
PTAB(1) := 100;
DBMS_OUTPUT.PUT_LINE('VALUE AT INDEX(1) IS '||PTAB(1));
PTAB.EXTEND(5,1);
DBMS_OUTPUT.PUT_LINE(‘VALUE AT INDEX(4) IS '||PTAB(4));
END;

VALUE AT INDEX(1) IS 100
VALUE AT INDEX(4) IS 100

PL/SQL procedure successfully completed.


Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 71 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?