A record is a group of related data items stored in fields, each with its own name and datatype. For example, suppose you have different kinds of data about a customer, such as name, address, city, state, zip code, and phone number. As shown below, a record allows you to relate dissimilar information in a way that appears cohesive and logical:
PL/SQL records are similar in structure to records in a 3GL.
PL/SQL records are not the same as rows within a database table.
PL/SQL records treat a collection of fields as a logical unit of work.
PL/SQL records are convenient for fetching a row of data from a table for processing.
PL/SQL records must contain one or more components of any SCALAR, RECORD, or PL/SQL TABLE datatype, called fields.
Creating a PL/SQL Record
Like PL/SQL tables, records must be declared in two steps. First, define the record type, then declare user-defined records of that type.
The record type can be declared within the declarative part of any block, subprogram, or package.
The field declarations are like variable declarations. Each field has a unique name and specific datatype.
The NOT NULL constraint can also be added to any field declaration, provided the declaration is initialized.
The following graphic explains the variables in the syntax:
The following graphic shows an example of declaring a PL/SQL record:
Composite Types used In PL/SQL
In the next lesson, you will learn about %Type attributes.
Click the link below to read about how to build a PL/SQL block with the RECORD datatype by using an evaluative simulation.
PL/SQL Composite Types