The SQL Descriptor Area and Data Type Conversion

You declare an SQL descriptor area using the SQLDA_T and SQLVAR_T structures defined in the proesql.h header file. The SQLVAR_T structure describes the C data type and storage characteristic for one column of an SQL table. The following tables describe the members of this structure that specify the data type of the column.

The TYPE Member

Table B–3 shows the supported relationship between each SQL data type, its corresponding SQLVAR_T->TYPE code (defined in proesql.h), and the required C data type for storage allocated for the SQLVAR_T->TYPE.

Table B–3: Matching Dynamic SQL and C Data Types  
SQL Data Type
SQLVAR_T->TYPE
C Data Type
CHARACTER
SQLDACHAR
char
DATE1
SQLDADATE
sqldate (char)
DECIMAL
SQLDADEC
sqldec (char)
DOUBLE PRECISION
SQLDADBL
double
FLOAT
SQLDAFLT
float
INTEGER
SQLDAINT
long
LOGICAL1
SQLDALOG
sqlbool (char)
NUMERIC
SQLDANUM
sqldec (char)
REAL
SQLDAREAL
float
SMALLINT
SQLDASML
short
  1. These are non-standard, Progress-defined SQL data types.

If you use the EXEC SQL DESCRIBE... statement or the sqldyndesc() function, ESQL-LIB fills in the SQL descriptor area (SQLVAR_T->TYPE) with appropriate data types for the statement columns. If you prepare the SQL descriptor for dynamic parameter markers using the sqldyndescinp() function, ESQL-LIB fills in the SQL descriptor area with the data types of the dynamic parameter markers.

If you fill in the descriptor area, before a FETCH, EXECUTE, or OPEN, the actual Progress data type of the table column might not correspond to the SQL data type that you specify in the SQL descriptor area. If possible, Progress converts the data into a meaningful form using the available source and target data types, as described in the “Output Data Conversion” and “Input Data Conversion” sections.

The PRECISION, SCALE, and LENGTH Members

As part of data conversion, ESQL uses the PRECISION, SCALE, and LENGTH members in the SQLVAR_T structure depending on the Progress data type involved in the conversion.

Table B–4 shows the actual use of PRECISION for each Progress data type after a call to sqldyndesc().

Table B–4: Precision of SQL Descriptor Data Types  
Progress
Data Type

SQLVAR_T->PRECISION
CHARACTER
N/A
DATE
N/A
DECIMAL
The defined maximum number of digits. For example, the precision of a column defined as DECIMAL(10,3) is 10.
INTEGER
N/A
LOGICAL
N/A

The SCALE member specifies the maximum number of digits to the right of the decimal point for a precisely scaled numeric data type.

Table B–5 shows the actual use of SCALE for each Progress data type after a call to sqlsqldyndesc().

Table B–5: Scale of SQL Descriptor Data Types
Progress
Data Type

SQLVAR_T->SCALE
CHARACTER
N/A
DATE
N/A
DECIMAL
The defined number of digits to the right of the decimal place. For example, the scale of a column defined as DECIMAL(10,3) is 3. For approximate floating point data types in the SQLVAR_T structure (for example, SQLDAFLT or SQLDADBL), the scale is undefined because the number of digits to the right of the decimal point is not fixed.
INTEGER
N/A
LOGICAL
N/A

The LENGTH member specifies the maximum number of bytes returned to the application when data is transferred to its default C data type.

Table B–6 shows the actual usage of LENGTH for each Progress data type after a call to sqldyndesc().

Table B–6: Output Length of SQL Descriptor Data Types  
Progress
Data Type
SQLVAR_T->LENGTH
CHARACTER
The defined length of the column, not including the null termination byte. For example, the output length of a column defined as CHAR(10) is 10, with one extra byte for the null terminator.
DATE
N/A
DECIMAL
N/A
INTEGER
N/A
LOGICAL
N/A


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095