About SQLDAs

SQLDA is a host-language structure that, like an SQL descriptor, describes the variables used in a dynamic SQL prepared statement. Unlike SQL descriptors, SQLDAs are public data structures whose fields you can access. Statements using SQLDAs may execute faster than equivalent statements using SQL descriptors.

The SQLDA structure is not part of the SQL standard. Different implementations of Embedded SQL define the SQLDA structure differently. Embedded SQL version 11.1 and later supports the SQLDA defined by Sybase; it does not support SQLDA datatypes defined by other vendors.

To define the SQLDA datatype in your Embedded SQL program, you use the Embedded SQL command include sqlda. To allocate a SQLDA structure in your program, you use the malloc function. To deallocate an SQLDA, you use the free function. Your program is responsible for deallocating all SQLDA structures that it creates. Embedded SQL does not limit the number of SQLDA structures that can be created by a program.

Table 7-1 describes the fields of the SQLDA structure.

Table 7-1: Fields of the SQLDA structure

Field

Datatype

Description

sd_sqln

CS_SMALLINT

The size of the sd_column array.

sd_sqld

CS_SMALLINT

The number of columns in the query being described, or 0 if the statement being described is not a query. For fetch, open, and execute statements, this field indicates the number of host variables described by occurrences of sd_column, or the number of dynamic parameter markers for the describe input statement.

sd_column[].sd_datafmt

CS_DATAFMT

Identifies the Client-Library CS_DATAFMT structure associated with this column. Refer to descriptions of ct_bind, ct_param , and ct_describe in the Open Client Client-Library/C Reference Manual for more information.

sd_column[].sd_sqldata

CS_VOID

For fetch, open, and execute statements, stores the address of the statement’s host variable. This field is not used for describe or prepare statements.

sd_column[].sd_sqlind

CS_SMALLINT

For fetch, open, and execute statements, this field acts as an indicator variable for the column being described. If the column’s value is null, this field is set to -1. This field is not used for describe or prepare statements.

sd_column[].sd_sqllen

CS_INT

The actual size of the data pointed to by sd_sqldata associated with this column.

sd_column[].sd_sqlmore

CS_VOID

Reserved.

The Embedded SQL header file sqlda.h contains a macro, SQLDADECL, that lets you declare SQLDA structures in your program. The SQLDADECL macro is as follows:

#ifndef SQLDADECL
 #define SQLDADECL(name, size)
     struct {
         CS_INT    sd_sqln;
         CS_INT    sd_sqln;
         struct {
             CS_DATAFMT     sd_datafmt;
             CS_VOID        sd_sqldata;
             CS_SMALLINT    sd_sqlind;
             CS_INT         sd_sqllen;
             CS_VOID        sd_sqlmore;
         } sd_column[ (SIZE) ]
     } name
 #endif /* SQLDADECL */