PL/SQL Records
A PL/SQL record is a collection of basic types of data and can be accessed as a single unit.
PL/SQL records are similar in structure to a row in a database table.
A record consists of components of any scalar, PL/SQL record, or PL/SQL table type.
It makes your life easier by transferring the entire row into a record, rather than transferring each column into a variable separately.
PL/SQL supports three kinds of records:
Important points on records
1. Individual fields are referenced via dot notation:
record_name.field_name
Example:
Emp_rec.first_name
2. Individual fields within a record can be read from or written to. They can appear on either the left or right side of the assignment operator:
BEGIN
policy_start_date:= new_emp_rec.hire_date + 30;
new_emp_rec.present:= FALSE;
3. An entire record can be assigned to another record of the same type.
However the assignment can fail, if you do not conform to these rules:
A PL/SQL record is a collection of basic types of data and can be accessed as a single unit.
PL/SQL records are similar in structure to a row in a database table.
A record consists of components of any scalar, PL/SQL record, or PL/SQL table type.
It makes your life easier by transferring the entire row into a record, rather than transferring each column into a variable separately.
PL/SQL supports three kinds of records:
Important points on records
1. Individual fields are referenced via dot notation:
record_name.field_name
Example:
Emp_rec.first_name
2. Individual fields within a record can be read from or written to. They can appear on either the left or right side of the assignment operator:
BEGIN
policy_start_date:= new_emp_rec.hire_date + 30;
new_emp_rec.present:= FALSE;
3. An entire record can be assigned to another record of the same type.
However the assignment can fail, if you do not conform to these rules:
- Both cursor-based records in a collective assignment must be based on the same cursor.
- Both table-based records in a collective assignment must be based on the same table.
- Both programmer-defined records in a collective assignment must be based on the same TYPE...RECORD statement.
No comments:
Post a Comment