Skip to content

Rowtype Attribute In Pl/Sql What Is The Assignment Operator

Variable

A variable holds a value that can change.

A variable declaration specifies its name, data type, and value, and allocates storage for it. The declaration can also assign an initial value and impose the constraint.

Syntax

variable_declaration ::=


Description of the illustration variable_declaration.gif

(expression ::=)

datatype ::=


Description of the illustration datatype.gif

Keyword and Parameter Descriptions

collection_name

A collection (associative array, nested table, or varray) previously declared within the current scope.

collection_type_name

A user-defined collection type defined using the data type specifier or .

cursor_name

An explicit cursor previously declared within the current scope.

cursor_variable_name

A PL/SQL cursor variable previously declared within the current scope.

db_table_name

A database table or view that must be accessible when the declaration is elaborated.

db_table_name.column_name

A database table and column that must be accessible when the declaration is elaborated.

expression

The value to be assigned to the variable when the declaration is elaborated. The value of must be of a data type that is compatible with the data type of the variable.

NOT NULL

A constraint that prevents the program from assigning a null value to the variable. Assigning a null to a variable defined as raises the predefined exception .

object_name

An instance of an object type previously declared within the current scope.

record_name

A user-defined or record previously declared within the current scope.

record_name.field_name

A field in a user-defined or record previously declared within the current scope.

record_type_name

A user-defined record type that is defined using the data type specifier .

ref_cursor_type_name

A user-defined cursor variable type, defined using the data type specifier .

%ROWTYPE

Represents a record that can hold a row from a database table or a cursor. Fields in the record have the same names and data types as columns in the row.

scalar_datatype_name

A predefined scalar data type such as , , or . Includes any qualifiers for size, precision, and character or byte semantics.

%TYPE

Represents the data type of a previously declared collection, cursor variable, field, object, record, database column, or variable.

variable_name

The name of the variable. For naming conventions, see Identifiers.

Usage Notes

Variables are initialized every time a block or subprogram is entered. By default, variables are initialized to . Whether public or private, variables declared in a package specification are initialized only once for each session.

An initialization clause is required when declaring variables. If you use to declare a variable, initialization is not allowed.

Examples

Related Topics

The attribute lets you declare a record that represents either a full or partial row of a database table or view.

For every visible column of the full or partial row, the record has a field with the same name and data type. If the structure of the row changes, then the structure of the record changes accordingly. Making an invisible column visible changes the structure of some records declared with the attribute.

The record fields do not inherit the constraints or initial values of the corresponding columns.

rowtype_attribute

explicit_cursor_name

Name of an explicit cursor. For every column selected by the query associated with , the record has a field with the same name and data type.

cursor_variable_name

Name of a strong cursor variable. For every column selected by the query associated with , the record has a field with the same name and data type.

db_table_or_view_name

Name of a database table or view that is accessible when the declaration is elaborated. For every column of , the record has a field with the same name and data type.

Examples

  • Example 5-38, "%ROWTYPE Variable Represents Full Database Table Row"

  • Example 5-39, "%ROWTYPE Variable Does Not Inherit Initial Values or Constraints"

  • Example 5-40, "%ROWTYPE Variable Represents Partial Database Table Row"

  • Example 5-41, "%ROWTYPE Variable Represents Join Row"

  • Example 5-44, "%ROWTYPE Affected by Making Invisible Column Visible"

  • Example 5-46, "Assigning %ROWTYPE Record to RECORD Type Record"

Related Topics

In this chapter:

In other chapters: