Download Informix Guide to SQL: Syntax

Transcript
GET DESCRIPTOR
For more information about TYPE, ILENGTH, IDATA, and ITYPE, see the
related dynamic management chapter in the appropriate Informix SQL API
programmer’s manual. For more information about programming in
X/Open mode, see the preprocessing and compilation syntax in the
appropriate Informix SQL API programmer’s manual. ♦
If the TYPE of a fetched value is DECIMAL or MONEY, the database server
returns the precision and scale information for a column into the PRECISION
and SCALE fields after a DESCRIBE statement is executed. If the TYPE is not
DECIMAL or MONEY, the SCALE and PRECISION fields are undefined.
Using the VALUE Clause After a FETCH
Each time your program fetches a row, it must copy the fetched value into
host variables so that the data can be used. To accomplish this task, use a GET
DESCRIPTOR statement after each fetch of each value in the select list. If three
values exist in the select list, you need to use three GET DESCRIPTOR statements after each fetch (assuming you want to read all three values). The item
numbers for each of the three GET DESCRIPTOR statements are 1, 2, and 3.
The following INFORMIX-ESQL/C example shows how you can copy data
from the DATA field into a host variable (result) after a fetch. For this
example, it is predetermined that all returned values are the same data type.
EXEC SQL get descriptor 'demodesc' :desc_count = count;
.
.
.
EXEC SQL fetch democursor using sql descriptor 'demodesc';
for (i = 1; i <= desc_count; i++)
{
if (sqlca.sqlcode != 0) break;
EXEC SQL get descriptor 'demodesc' value :i :result = DATA;
printf("%s ", result);
}
printf("\n");
1-318
Informix Guide to SQL: Syntax