HOWTO USE PLSQL NESTED TABLE IN SHORT

PLSQL Collections are not as much used as Java Collections. Below a short example of most of the futures of Nested Table collection type.


DECLARE
TYPE NTBLTYPE IS TABLE OF NUMBER;
V1 NTBLTYPE;
BEGIN
V1 := NTBLTYPE(1,2,3);

FOR i in 1..V1.COUNT LOOP
dbms_output.put_line(i || ' ' || v1(i));
END LOOP;

FOR i in V1.FIRST..V1.LAST LOOP
dbms_output.put_line(i || ' ' || v1(i));
END LOOP;

V1.delete(1);
-- VARRAY - you can only delete the last element
-- VARRAY - constructor alloacates the whole length of array
nested table is dynamically allocated

END;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s