The rtypsize() function

The rtypsize() function returns the internal storage sizes of data for clients that use the Change Data Capture API.

Syntax

mint rtypsize(sqltype, sqllen)
   mint sqltype;
   mint sqllen;
sqltype
The integer code of the Informix® ESQL/C or SQL data type. For more information, see Data type constants.
sqllen
The number of bytes in the data file for the specified data type.

Usage

While similar to the rtypmsize() function, the rtypsize() function returns internal server storage lengths rather than ESQL/C data lengths.

The rtypsize() function is provided to use with the sqlda structure that a DESCRIBE statement initializes. After a DESCRIBE statement determines column information, the value of sqltype and sqllen components are in the components of the same name in each sqlda.sqlvar structure.

You can see an application of the rtypsize() function in the cdcapi.ec sample program in the demo directory.

Return codes

0
The sqltype is not a valid SQL type.
>0
The return value is the number of bytes that the sqltype data type requires.

Example

The following code fragment from the cdcapi.ec file in the demo directory shows the usage of the rtypsize() function.
 sprintf(sql_stm, "select * from %s", tabname);
 $prepare select_id from $sql_stm;
    CHK_SQL_CODE(sql_stm);

    $describe select_id into sqlda;
    CHK_SQL_CODE("Describe");

    /*
     *  Save the description of the column descriptor for the table.
     *  We will use this later to process the insert/update/delete records
     *  for this table.
     */
    for (col = 0; col < sqlda->sqld; col++)
                {
                colsize = rtypsize(sqlda->sqlvar[col].sqltype, 
                                                sqlda->sqlvar[col].sqllen);
                printStdoutAndFile("\tColumn %d is %s, type = %d, size = %d\n", col, 
                sqlda->sqlvar[col].sqlname, sqlda->sqlvar[col].sqltype, colsize);

                coldesc.colobj[col].coltype = sqlda->sqlvar[col].sqltype;
                coldesc.colobj[col].colsize = colsize;
                coldesc.colobj[col].colxid = sqlda->sqlvar[col].sqlxid;
                coldesc.colobj[col].colname = 
                        malloc(strlen(sqlda->sqlvar[col].sqlname)+1);
                strcpy(coldesc.colobj[col].colname, sqlda->sqlvar[col].sqlname);
                }
        coldesc.num_of_columns = col;