Home | Previous Page | Next Page   DataBlade API Overview > Accessing SQL Data Types > Type Descriptors >

Data Type Descriptors and Column Type Descriptors

A type descriptor for a data type and a type descriptor for a column use the same accessor functions and share the same underlying data type structures. These descriptors differ, however, in the handling of parameterized data types (such as DATETIME, INTERVAL, DECIMAL, and money), as follows:

Table 9 lists the DataBlade API accessor functions that obtain information from a type descriptor. When you use type-descriptor accessor functions on parameterized data types, the results depend on which kind of type descriptor you pass into the accessor function.

For example, Figure 1 shows a named row type with fields that have parameterized data types.

Figure 1. Sample Named Row Type with Parameterized Fields
CREATE ROW TYPE row_type 
   (time_fld DATETIME YEAR TO SECOND, 
    dec_fld DECIMAL(6,3));

Figure 2 shows a code fragment that obtains a data type descriptor and a column type descriptor for the first field (time_fld) from the row descriptor (row_desc) for the row_type row type.

Figure 2. Type Descriptor and Column Type Descriptor for DATETIME Field
type_id = mi_column_type_id(row_desc, 0);
type_desc = mi_type_typedesc(conn, type_id);
col_type_desc = mi_column_type_desc(row_desc, 0);

For the DATETIME data type of the time_fld column, the type-descriptor accessor functions obtain different qualifier information for each kind of type descriptor, as follows:

Similarly, for DECIMAL and MONEY data types, the type-descriptor accessor functions can obtain scale and precision information from a column type descriptor but not a data type descriptor. Figure 3 shows a code fragment that obtains a data type descriptor and a column type descriptor for the second field (dec_fld) from the row descriptor (row_desc) for the row_type row type.

Figure 3. Type Descriptor and Column Type Descriptor for DECIMAL Field
type_id2 = mi_column_type_id( row_desc, 1 );
type_desc2 = mi_type_typedesc( conn, type_id2 );
col_type_desc2 = mi_column_type_desc( row_desc, 1 );

For the DECIMAL data type of the dec_fld column, the results from the type-descriptor accessor functions depend on which type descriptor you pass into the accessor function, as follows:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]