Thursday, January 4, 2018

PLSQL Table Type

Hi , Some time we may need to process a table of records for which you might need to create a temporary table to process the records.

To avoid SQL Table we can use PLSQL table as given below

DECLARE
   TYPE t_record IS TABLE OF VARCHAR (30);
   TYPE t_tab IS TABLE OF t_record;

   v_tab   t_tab := t_tab ( t_record ('1', '2', '3')

                          , t_record ('A', 'B', 'C')
                          );
BEGIN
   FOR i IN 1 .. v_tab.COUNT
   LOOP
      DBMS_OUTPUT.put_line (v_tab (i) (1) || v_tab (i) (2) || v_tab (i) (3));
   END LOOP;
END;
/

No comments: