INCLUDE SQLDA declarations
This section shows the equivalent INCLUDE SQLDA declaration for C and C++, COBOL, ILE COBOL, PL/I, and ILE RPG.
For C and C++
In C and C++, INCLUDE SQLDA declarations are equivalent to the following:
/*********************************************************************/
/* Macros for using the sqlvar2 fields. */
/*********************************************************************/
/*********************************************************************/
/* '2' in the 7th byte of sqldaid indicates a doubled number of */
/* sqlvar entries. */
/* '3' in the 7th byte of sqldaid indicates a tripled number of */
/* sqlvar entries. */
/* '4' in the 7th byte of sqldaid indicates a quadrupled number of */
/* sqlvar entries. */
/*********************************************************************/
#define SQLDOUBLED '2'
#define SQLSINGLED ' '
/*********************************************************************/
/* GETSQLDOUBLED(daptr) returns 1 if the SQLDA pointed to by */
/* daptr has been doubled, or 0 if it has not been doubled. */
/*********************************************************************/
#define GETSQLDOUBLED(daptr) (((daptr)->sqldaid[6]== \
(char) SQLDOUBLED) ? \
(1) : \
(0) )
/*********************************************************************/
/* SETSQLDOUBLED(daptr, SQLDOUBLED) sets the 7th byte of sqldaid */
/* to '2'. */
/* SETSQLDOUBLED(daptr, SQLSINGLED) sets the 7th byte of sqldaid */
/* to be a ' '. */
/*********************************************************************/
#define SETSQLDOUBLED(daptr, newvalue) \
(((daptr)->sqldaid[6] =(newvalue)))
/*********************************************************************/
/* GETSQLDALONGLEN(daptr,n) returns the data length of the nth */
/* entry in the sqlda pointed to by daptr. Use this only if the */
/* sqlda was doubled or tripled and the nth SQLVAR entry has a */
/* LOB datatype. */
/*********************************************************************/
#define GETSQLDALONGLEN(daptr,n) ((long) (((struct sqlvar2 *) \
&((daptr)->sqlvar[(n) +((daptr)->sqld)])) ->len.sqllonglen))
/*********************************************************************/
/* SETSQLDALONGLEN(daptr,n,len) sets the sqllonglen field of the */
/* sqlda pointed to by daptr to len for the nth entry. Use this only */
/* if the sqlda was doubled or tripled and the nth SQLVAR entry has */
/* a LOB datatype. */
/*********************************************************************/
#define SETSQLDALONGLEN(daptr,n,length) { \
struct sqlvar2 *var2ptr; \
var2ptr = (struct sqlvar2 *) &((daptr)->sqlvar[(n)+ \
((daptr)->sqld)]); \
var2ptr->len.sqllonglen = (long) (length); \
}
/*********************************************************************/
/* SETSQLDALENPTR(daptr,n,ptr) sets a pointer to the data length for */
/* the nth entry in the sqlda pointed to by daptr. */
/* Use this only if the sqlda has been doubled or tripled. */
/*********************************************************************/
#define SETSQLDALENPTR(daptr,n,ptr) { \
struct sqlvar2 *var2ptr; \
var2ptr = (struct sqlvar2 *) &((daptr)->sqlvar[(n)+ \
((daptr)->sqld)]); \
var2ptr->sqldatalen = (char *) ptr; \
}
/*********************************************************************/
/* GETSQLDALENPTR(daptr,n) returns a pointer to the data length for */
/* the nth entry in the sqlda pointed to by daptr. Unlike the inline */
/* value (union sql8bytelen len), which is 8 bytes, the sqldatalen */
/* pointer field returns a pointer to a long (4 byte) integer. */
/* If the SQLDATALEN pointer is zero, a NULL pointer is be returned. */
/* */
/* NOTE: Use this only if the sqlda has been doubled or tripled. */
/*********************************************************************/
#define GETSQLDALENPTR(daptr,n) ( \
(((struct sqlvar2 *) &(daptr)->sqlvar[(n) + \
(daptr)->sqld])->sqldatalen == NULL) ? \
((long *) NULL ) : ((long *) ((struct sqlvar2 *) \
&(daptr)->sqlvar[(n) + (daptr) ->sqld])->sqldatalen))
For COBOL and ILE COBOL
In COBOL and ILE COBOL, INCLUDE SQLDA declarations are equivalent to the following:
For PL/I
In PL/I, INCLUDE SQLDA declarations are equivalent to the following:
For ILE RPG
In ILE RPG, INCLUDE SQLDA declarations are equivalent to the following:
The user is responsible for the definition of SQL_NUM. SQL_NUM must be defined as a numeric constant with the dimension required for SQL_VAR.
Since RPG does not support structures within arrays, the SQLDA generates three data structures. The second and third data structures are used to setup/reference the part of the SQLDA which contains the field descriptions.
To set the field descriptions of the SQLDA the program sets up the field description in the subfields of SQLVAR (or SQLVAR2) and then does a MOVEA of SQLVAR (or SQLVAR2) to SQL_VAR, n where n is the number of the field in the SQLDA. This is repeated until all the field descriptions are set.
When the SQLDA field descriptions are to be referenced the user does a MOVEA of SQL_VAR, n to SQLVAR (or SQLVAR2) where n is the number of the field description to be processed.