DESCRIBE TYPE statement (Receive definition information on user-defined data type)
Function
When a user-defined data type is contained directly or indirectly# in retrieval item information for an SQL statement preprocessed by a PREPARE statement, the DESCRIBE TYPE statement is used to receive the definition information (attribute data codes and data lengths) on the user-defined data type into the SQL descriptor area.
When preprocessing is performed without specifying the WILL ALL TYPE OPTION in the PREPARE statement, definition information on the user-defined data type cannot be received. In such a case, if all encapsulation levels of the attributes of the user-defined data type are other than PUBLIC, 0 is set in the SQLD area of the SQL descriptor area.
#: A user-defined data type is contained directly when the column containing the retrieval item information has a user-defined data type. A user-defined data type is contained indirectly when the column containing the retrieval item information has a user-defined data type and also contains attributes of the user-defined data type (i.e., nested user-defined data type).
Privileges
Format
DESCRIBE TYPE :embedded-variable-1 :embedded-variable-2
FOR { SQL-statement-identifier | extended-statement-name} INTO
[:]SQL-descriptor-area-name
[[:]Column-Name-Descriptor-Area-name]
[TYPE [:]Type-Name-Descriptor-Area-name]
Operands
- TYPE : embedded-variable-1 : embedded-variable-2 FOR {SQL-statement-identifier | extended-statement-name}
- embedded-variable-1
- Specifies a VARCHAR(8) embedded variable that stores the name of the owner of the user-defined data type.
- embedded-variable-2
- Specifies a VARCHAR(30) embedded variable that stores the data type identifier of the user-defined data type.
- SQL-statement-identifier
- Specifies the SQL statement identifier that was specified in the PREPARE statement.
- [:] SQL-descriptor-area-name [[:] Column-Name-Descriptor-Area-name] [TYPE [:] Type-Name-Descriptor-Area-name]
- SQL-descriptor-area-name
- Specifies the name of the SQL descriptor area that receives attribute information on the user-defined data type. For details about descriptor areas, see the HiRDB Version 9 UAP Development Guide.
- extended-statement-name
- Specifies the extended statement name that identifies the SQL statement preprocessed by the PREPARE statement.
- For extended statement names, see 2.26 Extended statement name.
- Column-Name-Descriptor-Area-name
- Specifies the name of the Column Name Descriptor Area that receives the attribute name for the user-defined data type. For details about Column Name Descriptor Areas, see the HiRDB Version 9 UAP Development Guide.
- Type-Name-Descriptor-Area-name
- When the attribute of the user-defined data type is a user-defined data type, specifies the name of the Type Name Descriptor Area that receives the name of the user-defined data type of user-defined type. For details about Type Name Descriptor Areas, see the HiRDB Version 9 UAP Development Guide.
Common rules
- The number of SQLVARs (SQLN area) in the SQL descriptor area must be assigned by the UAP before the DESCRIBE TYPE statement is executed.
- The following items are assigned: data type of the attribute of the user-defined data type (assigned in the SQL descriptor area), name of the attribute (assigned in the Column Name Descriptor Area), and the name of the user-defined data type when the data type of the attribute is the user-defined type (assigned in the Type Name Descriptor Area).
- If a specified abstract data type inherited the attributes of a higher-level data type, information on the inherited attributes will also be assigned. In such a case, attributes are set in the following order: inherited attributes first, then attributes specific to the abstract data type.
- User-defined data types cannot be specified, other than those that are directly or indirectly included in the SQL retrieval items specified in the PREPARE statement.
- Definition information on an attribute cannot be obtained if the encapsulation level of the attribute is not PUBLIC.
- When a Column Name Descriptor Area is specified, WITH SQLNAME OPTION must be specified in the corresponding PREPARE statement.
Note
An SQL statement identifier, as embedded variables, is effective in a compile-unit file. Multiple SQL statements with the same SQL statement identifier cannot be used in multiple modules.
Example
Specify attribute information, the attribute name, and the user-defined data type for the attribute of a user-defined data type (embedded variable 1 is WUSERID; embedded variable 2 is WTYPENAME) obtained by a SELECT statement (SQL statement identifier is PRESQL) preprocessed by a PREPARE statement in the following areas: an SQL descriptor area, a Column Name Descriptor Area, and a Type Name Descriptor Area:
DESCRIBE TYPE :WUSERID :WTYPENAME
FOR PRESQL INTO :SQLDA :SQLCNDS :SQLTNDA