Introduction to PL/SQL (Composite Data Type)


Composite data type: Composite data type stores values that have internal components. You can pass entire composite variables to subprograms as parameters, and you can access internal components of composite variables individually. Internal components can be either scalar or composite. You can use scalar components wherever you can use scalar variables or you can use composite components wherever you can use composite variables of the same type. There are two types of composite data type…

  • 1. PL/SQL records.
  • 2. PL/SQL collection.
    • INDEX by Table
    • Nested Table
    • VARRAY

1. PL/SQL records: Use PL/SQL records when you want to store values of different data types but only one occurrence at a time. PL/SQL record must contain one or more components (called fields) of any scalar, RECORD or Index by table data type.

Creating PL/SQL records:

Example:

Using %ROWTYPE in composite data type: The %ROWTYPE attribute is useful when the number and data types of the underlying database columns is unknown and  retrieving a row with the SELECT * from statement.

Example:

 

Tags:

You may also like

LEAVE A COMMENT

*

Follow Me

Oracle Certification