Subject SELECTing floats through the API
Author federonline
Hi...

I am trying to access float similar to example API6.c; I am attempting
to find the MAX Thermistor value for a type of thermistor (TEXT). The
values in the DB for the two variables (dA1 & szAO1) are 0.844 & 'TEXT'.

The string returns with the value '0x04TEXT', and the float (return)
value is 1.2687E87, which isn't 0.844 (or 20' Celsius).

I have a bout 8 other similar queries to migrate and this one is
killing me, so I'd reeally appreciate a hand.

Kurt.


//----------------------------------------------------------

double dA1;
char szAO1[32];
short flag[2];
ISC_STATUS fetch;



memset( szStatement, 0, 128 );
strcpy( szStatement, "select A1, A2, AO1, AO2 from V_LATEST_DAT " );
//strcat( szStatement, createWhereClause() );

SQLDA1 = (XSQLDA*)malloc( XSQLDA_LENGTH(5) );
SQLDA1->version = 1;
SQLDA1->sqln = 2;

SQLDA1->sqlvar[0].sqldata = (char*)&dA1;
SQLDA1->sqlvar[0].sqltype = SQL_DOUBLE + 1;
SQLDA1->sqlvar[0].sqllen = sizeof(dA1);
SQLDA1->sqlvar[0].sqlind = &flag[0];

SQLDA1->sqlvar[1].sqldata = (char *) szAO1;
SQLDA1->sqlvar[1].sqltype = SQL_TEXT+1;
SQLDA1->sqlvar[1].sqllen = 32;
SQLDA1->sqlvar[1].sqlind = &flag[1];

// RUN THE QUERY...
STMT1 = NULL;
if( isc_dsql_allocate_statement( STAT1, &DB, &STMT1 ) )
{
bSuccess = false;
bRetVal = false;
}
else
{
if( isc_dsql_prepare(STAT1, &TR1, &STMT1, 0, szStatement, 1, SQLDA1) )
{
bSuccess = false;
bRetVal = false;
}
}

if( bRetVal )
{
if( isc_dsql_execute( STAT1, &TR1, &STMT1, 1, NULL ) )
{
bSuccess = false;
bRetVal = false;
}
}

if( bRetVal == true )
{
while( 0 == (fetch = isc_dsql_fetch(STAT1, &STMT1, 1, SQLDA1)) )
{
if( (flag[0] == 0)
&& (strstr( szAO1, "TEXT" ) == 0)
&& ( dA1 > fMaxDAT ) )
{
fMaxDAT = dA1;
}
}

isc_commit_retaining( STAT1, &TR1 );
isc_dsql_free_statement(STAT1, &STMT1, DSQL_close);
}