(Contents)(Previous)(Next)

ADABAS SQLDA Structure

sqldaid

Contains the character string 'SQLDA' and serves to facilitate the finding of the structure in a dump.

sqlmax

Maximum number of 'SQLVAR' entries. For the precompiler-generated SQLDA, a value is automatically assigned to 'sqlmax'. In all the other cases, the user must set 'sqlmax' to a value. The value must be large enough to have an SQLVAR entry for each column.

sqln

Number of 'SQLVAR' entries (input and output parameters) to be assigned. The DESCRIBE statement sets this value.

sqld

Number of output parameters (the column contents must be placed in a program variable). Columns which may be both input and output parameters are counted here as output parameters. The DESCRIBE statement sets this value.

sqlvar

One 'SQLVAR' entry will be created in the SQLDA for each parameter according to the sequence in the SQL statement. The default maximum number for SQLDA entries is 300. The user is allowed to define them in a new variable.

Structure of SQLVAR

ADABAS stores here the following information for each parameter:

colname

For 'fetch using descriptor', the name of the column is entered; for all other SQL statements 'columnx' is entered, with x as a consecutive number (1 to n) for the columns.

colio

Indicates whether an input or an output parameter is involved.

sqlinppar (0) ::= input parameter

sqloutpar (1) ::= output parameter

sqlinoutpar (2) ::= input/output parameter

colmode

Indicates whether null values are allowed.

sqlval (0) ::= not allowed

sqlundef (1) ::= allowed

coltype

Supplies the ADABAS type.

sqlfixed (0) ::= fixed number

sqlfloat (1) ::= float number

sqlchar (2) ::= character

sqlbyte (3) ::= byte

sqldate (4) ::= date

sqltime (5) ::= time

sqlexpr (7) ::= float number

sqltimestamp (8) ::= timestamp

sqloldlongchar (11) ::= old long

sqloldlongbyte (12) ::= old long byte

sqlsmallint (15) ::= short integer

sqlinteger (16) ::= integer

sqlvarchar (17) ::= varchar

sqlescapechar (18) ::= escape char

sqllong (19) ::= long

sqllongbyte (20) ::= long byte

sqlboolean (23) ::= boolean

collength

Number of the total places for numeric columns, otherwise, the number of characters. Can be set by the user to the length of the program variables. Such an adaptation is required whenever the number of characters increases by 1 because of the zero byte.

colfrac

Number of places after the decimal point. For coltype = float_number, this array holds -1. Can be set by the user to the length of the program variables.

hostindicator

Contains the indicator value. For input parameters, it can be set, for output parameters, it must be checked, since in the case of a null value, the program variable will not be overwritten!

hostvartype

Contains the data type designation for the program variable and must be assigned by the user. For the describe statement, ADABAS sets this parameter to -1. 'collength' and 'colfrac' must be changed according to the data type.

sqlvint2 (0) ::= integer (2 bytes long)

sqlvint4 (1) ::= integer (4 bytes long)

sqlvuns2 (16) ::= unsigned integer

(2 bytes long)

sqlvuns4 (17) ::= unsigned integer

(4 bytes long)

sqlvreal4 (2) ::= float (4 bytes long)

sqlvreal8 (3) ::= float (8 bytes long)

(6) ::= char-array (1 byte long,

without 0 byte

termination)

sqlvchar (7) ::= char-array

(terminated with 0 byte)

sqlvstring2 (15) ::= variable string

(2 bytes len, char array )

sqlvstring1 (20) ::= variable string

(1 byte len, char array )

sqlvint8 (33) ::= integer (8 bytes long)

sqlvstring4 (35) ::= variable string

(4 bytes len, char array)

hostcolsize

For ARRAY statements, the size of program variables must be specified here in bytes.

hostvaraddr

Contains the address of the program variable assigned to the parameter. The describe statement initializes it to zero; the user must assign the address of the program variable to it. For array statements, this is the address of the first element.

hostindaddr

For array statements, the address of the indicator array must be specified here. If indicators are not used, NULL must be specified. For simple SQL statements, the address of a variable can be specified here. Then the indicator is written into this variable and 'hostindicator' is undefined.

colinfo

Must not be modified, because internal information is stored here that is needed for the conversion of program variables.

SQLDA Declaration

typedef struct {

char sqldaid[8];

sqlint4 sqlmax;

sqlint2 sqln,

sqld,

sqlint4 sqlloop,

sqloffset;

sqlint2 sqlkano,

sqlprno,

sqlkamode,

sqlfiller;

sqlint4 sqlfiller2;

sqlvartype sqlvar[sqlnmax];

}

sqldatype;

typedef struct {

sqlnname colname;

sqlint2 colio,

colmode,

coltype;

sqlint4 collength;

sqlint2 colfrac,

colfiller,

hostvartype,

hostcolsize;

sqlint4 hostindicator;

void *hostvaraddr;

sqlint4 *hostindaddr;

struct SQLCOL col;

}

sqlvartype;


(Contents)(Previous)(Next)