DB2 10.5 for Linux, UNIX, and Windows

TYPE_ID scalar function

The TYPE_ID function returns the internal type identifier of the dynamic data type of the expression.

Read syntax diagramSkip visual syntax diagram
>>-TYPE_ID--(--expression--)-----------------------------------><

The schema is SYSIBM.

expression
An expression that returns a value of a user-defined structured data type.

The data type of the result of the function is INTEGER. If expression can be null, the result can be null; if expression is null, the result is the null value.

The value returned by the TYPE_ID function is not portable across databases. The value may be different, even though the type schema and type name of the dynamic data type are the same. When coding for portability, use the TYPE_SCHEMA and TYPE_NAME functions to determine the type schema and type name.

Notes

Example

A table hierarchy exists having root table EMPLOYEE of type EMP and subtable MANAGER of type MGR. Another table ACTIVITIES includes a column called WHO_RESPONSIBLE that is defined as REF(EMP) SCOPE EMPLOYEE. For each reference in ACTIVITIES, display the internal type identifier of the row that corresponds to the reference.
   SELECT TASK, WHO_RESPONSIBLE->NAME,
       TYPE_ID(DEREF(WHO_RESPONSIBLE))
     FROM ACTIVITIES
The DEREF function is used to return the object corresponding to the row.