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
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 thesqldyndescinp()
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()
.
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()
.
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().
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |