SQL Descriptor Area (SQLDA)

The SQLDA provides the programmer with comprehensive information about each resulting column of a dynamic SELECT statement.

The following is the declaration of the SQLDA structure in C:

 

struct sqlda

 {

   unsigned char sqldaid [8];   /* eye catcher: 'SQLDA'      */

   SAG_INTEGER   sqldabc;       /* size of sqlda in bytes    */

   short         sqln;          /* #sqlvar elements allocated*/

   short         sqld;          /* #sqlvar elements returned */

   struct sqlvar

   { SAGTYPE     sqltype;       /* datatype of variable      */

     SAG_INTEGER sqllen;        /* length of variable        */

     SAG_INTEGER reserved;      /* reserved                  */

     short       internal;      /* reserved                  */

     short       sqlindlen;     /* length of indicator       */

     SAG_INTEGER sqlindtype;    /* datatype of indicator     */

     SAGPointer  sqlind;        /* pointer to indicator      */

     SAGPointer  sqldata;       /* pointer to data           */

     SAGCOLUMN   sqlname;       /* name of the column or HV  */

   } sqlvar [1];

 };

#define SQLDASIZE(n) (sizeof(struct sqlda)+(n-1)*sizeof(struct sqlvar))

 

SQL Data Type

C Definitions for Data Types Returned
or Set in sqltype and sqlindtype

Value

UNKNOWN

SQL_TYP_UNKNOWN

0

CHAR

SQL_TYP_CHAR

1

NUMERIC

SQL_TYP_NUMERIC

2

DECIMAL

SQL_TYP_DECIMAL

3

INTEGER

SQL_TYP_INTEGER

4

SMALLINT

SQL_TYP_SMALLINT

5

FLOAT

SQL_TYP_FLOAT

6

LARGEINT

SQL_TYP_LARGEINT

9

VARCHAR

SQL_TYP_VARCHAR

12

NUMERIC SIGNED LEADING

SQL_TYP_NUMERIC_LD

20

NUMERIC SIGNED TRAILING

SQL_TYP_NUMERIC_TR

21

NUMERIC SIGNED LEADING SEPARATE

SQL_TYP_NUMERIC_SLD

22

NUMERIC SIGNED LEADING TRAILING

SQL_TYP_NUMERIC_STR

23

NULLABLE_CHAR

SQL_TYP_NCHAR

-1

NULLABLE NUMERIC

SQL_TYP_NNUMERIC

-2

NULLABLE DECIMAL

SQL_TYP_NDECIMAL

-3

NULLABLE INTEGER

SQL_TYP_NINTEGER

-4

NULLABLE SMALLINT

SQL_TYP_NSMALLINT

-5

NULLABLE FLOAT

SQL_TYP_NFLOAT

-6

NULLABLE LARGEINT

SQL_TYP_NLARGEINT

-9

NULLABLE VARCHAR

SQL_TYP_NVARCHAR

-12

NULLABLE NUMERIC SIGNED LEADING

SQL_TYP_NNUMERIC_LD

-20

NULLABLE NUMERIC SIGNED TRAILING

SQL_TYP_NNUMERIC_TR

-21

NULLABLE NUMERIC SIGN LEADING

SQL_TYP_NNUMERIC_SLD

-22

NULLABLE NUMERIC SIGN TRAILING

SQL_TYP_NNUMERIC_STR

-23

BINARY

SQL_TYP_BINARY

-51

NULLABLE BINARY

SQL_TYP_NBINARY

-52

NATURAL DATE

SQL_TYP_NATDATE

-53

NULLABLE NATURAL DATE

SQL_TYP_NNATDATE

-54

NATURAL TIME

SQL_TYP_NATTIME

-55

NULLABLE NATURAL TIME

SQL_TYP_NNATTIME

-56

SQLDA

SQL_TYP_SQLDA

-57

NATURAL TIMESTAMP

SQL_TYP_NATTIMESTAMP

-58

NULLABLE NATURAL TIMESTAMP

SQL_TYP_NNATTIMESTAMP

-59