Creating a row data type
Creating a row data type is a prerequisite to creating a row variable.
Before you create a row data type:
- Read: Row types
- Read: Restrictions on the row data type
This task can be done from any interface that supports the execution of the CREATE TYPE statement.
To create a row data type within a database, you must successfully execute the CREATE TYPE (ROW) statement from any Db2® interface that supports the execution of SQL statements.
- Formulate a CREATE TYPE (ROW) statement:
- Specify a name for the type.
- Specify the row field definition for the row by specifying a name and data type for each field in the row.
CREATE TYPE empRow AS ROW (name VARCHAR(128), id VARCHAR(8)); - Execute the CREATE TYPE statement from a supported Db2 interface.
If the CREATE TYPE statement executes successfully, the row data type is created in the database. If the statement does not execute successfully, verify the syntax of the statement and verify that the data type does not already exist.
Once the row data type is created, row variables can be declared based on this data type.