DATAFMT structure

Description

A DATAFMT (data format) structure is used to describe data values and program variables. For example:

Most functions use only a subset of the fields in a DATAFMT structure. For example, ct_bind does not use the name, status, and usertype fields, and ct_describe does not use the format field. For information on which DATAFMT fields a function uses, see Table 2-3 in this chapter, or reference the desired function in Chapter 3, “Functions.”

A DATAFMT structure is defined as follows:

/**********************************************************************/
                     CT_DATAFMT  used for client/server API calls
/**********************************************************************/
 typedef struct _ct_datafmt {
             CS_CHAR name[CS_MAX_NAME]; /* name of the column/parm     */
             CS_INT  namelen;           /* actual length of the name   */
             CS_INT  datatype;          /* hostvar datatype            */
             CS_INT  format;            /* Pad or \0 terminate Bin/Char*/
             CS_INT  maxlength;         /* max length the data might be*/
             CS_INT  scale;             /* NUMERIC: scale value (only) */
             CS_INT  precision;         /* NUMERIC: precision value    */
             CS_INT  status;            /* datum status (key, ret parm)*/
             CS_INT  count;             /* BIND: how many rows to bind */
             CS_INT  usertype;          /* user defined datatype (UDT) */
             CS_LOCALE *locale;         /* localization struct pointer */
                    } CS_DATAFMT;

Table 2-3 describes fields in the DATAFMT structure.

Table 2-3: Fields in the DATAFMT structure

Field

Contents

Used by

name

The name of the data item.

ct_describe ct_param

namelen

The length of name.

ct_describe ct_param

datatype

The datatype of the data. See the specific call to find which data this refers to.

cs_convert ct_bind ct_describe ct_param

format

The format of the data, represented by symbolic values.

ct_bind

maxlength

The maximum length of the data.

cs_convert ct_bind ct_describe ct_param

scale

The number of digits in the decimal part of a number. This field is used with packed decimal, numeric and Sybase-decimal.

cs_convert ct_bind

precision

The total number of digits in a number. This field is used with packed decimal, numeric and Sybase-decimal.

cs_convert ct_bind

status

Status values.

ct_describe ct_param

count

The number of items.

ct_bind ct_describe

usertype

The user-defined datatype (UDT) of retrieved data. The UDT is assigned by the server.

ct_describe ct_param

locale

Reserved for future use.

cs_convert ct_bind ct_describe ct_param