Oralce record collection
Oracle record collection
Record
PL/SQL supports three types of records: table-based (table-based),
Cursor-based (cursor-based) and programmer defined (programmer-defined)
A table-based record is that the structure of the record comes from a list of all fields in the database table.
A cursor-based record is the structure of the record that comes from the select list of cursors.
To create a table-based or cursor-based record, you can make
Use the% ROWTYPE attribute. Syntax:
Record_name table_name or cursor_name%ROWTYPE
User-defined record
The syntax is as follows:
TYPE type_name IS RECORD-declare the record type
(field_name1 DATATYPE1
Field_name2 DATATYPE2
……
Field_nameN DATATYPEN)
Record_name TYPE_NAME;-- declaration record variable
Add: when a record type has only one field, it has no practical meaning equivalent to variable, but this field can come from cursor.
Set
How to write a declaration collection:
TYPE type_name IS TABLE OF element_type
INDEX BY index_type
TYPE type_name IS VARRAY (size_limit) OF element_type
Element_type can be:
Any datatype,suchas number
Table_name.column_name%type
Table_name%rowtype
Cursor_name%rowtype.