Home » SQL & PL/SQL » SQL & PL/SQL » pl/sql table
pl/sql table [message #4654] Mon, 06 January 2003 00:58 Go to next message
avishek kumar
Messages: 1
Registered: January 2003
Junior Member
How we will create PL/SQL table... tell me its advantage and disadvantage.....
Re: pl/sql table [message #4656 is a reply to message #4654] Mon, 06 January 2003 07:19 Go to previous message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
SQL> DECLARE
  2      TYPE auto IS RECORD (
  3          license_plate_no    VARCHAR2(10)
  4      ,   color               VARCHAR2(10)
  5      ,   make                VARCHAR2(20)
  6      ,   model               VARCHAR2(20)
  7      );
  8  
  9      TYPE auto_table IS TABLE OF auto
 10                      INDEX BY BINARY_INTEGER;
 11  
 12      garage          auto_table;
 13  
 14  BEGIN
 15      garage(1).license_plate_no := 'ABC 789';
 16      garage(1).color            := 'GREY';
 17      garage(1).make             := 'CHEVROLET';
 18      garage(1).model            := 'LUMINA';
 19      
 20      garage(2).license_plate_no := 'GGG 202';
 21      garage(2).color            := 'BLACK';
 22      garage(2).make             := 'HONDA';
 23      garage(2).model            := 'CIVIC';
 24  
 25      garage(3).license_plate_no := '303 XYZ';
 26      garage(3).color            := 'GREEN';
 27      garage(3).make             := 'PONTIAC';
 28      garage(3).model            := 'AZTEK';
 29  
 30      DBMS_OUTPUT.PUT_LINE('Count = ' || garage.COUNT);
 31  
 32      FOR i IN 1..garage.COUNT LOOP
 33          DBMS_OUTPUT.PUT_LINE('Color('
 34              || TO_CHAR(i)
 35              || ') = '
 36              || garage(i).color);
 37      END LOOP;
 38  END;
 39  /
Count = 3
Color(1) = GREY
Color(2) = BLACK
Color(3) = GREEN
     
PL/SQL procedure successfully completed.
     
SQL> 


For more about PL/SQL tables, click here.

Good luck,

Art.
Previous Topic: Utl_SMTP error
Next Topic: sending mail from pl/sql programming
Goto Forum:
  


Current Time: Sun Jun 09 04:37:45 CDT 2024