Is there SQL_TYP_REAL in UDB V8.1?

Hi,

I'm using SQLDA to fetched a row of data and then get values of each

column, and I'm using sqltype (sqlDA->sqlvar[i].sqltype) to decide how

to cast the corresponding sqldata (sqlDA->sqlvar[i].sqldata), but

there seem to be no SQL_TYP_REAL defined. If so, why there is this

data type for defining the table schema? Now all columns that are

defined as REAL cannot be converted correctly. Is there a way to go

around this or I have to change all the columns that have type REAL to

FLOAT?

Thanks.

Re: Is there SQL_TYP_REAL in UDB V8.1?

minjie <minjieexcite.com> wrote:

Quote:

> Hi,

> I'm using SQLDA to fetched a row of data and then get values of each

> column, and I'm using sqltype (sqlDA->sqlvar[i].sqltype) to decide how

> to cast the corresponding sqldata (sqlDA->sqlvar[i].sqldata), but

> there seem to be no SQL_TYP_REAL defined. If so, why there is this

> data type for defining the table schema? Now all columns that are

> defined as REAL cannot be converted correctly. Is there a way to go

> around this or I have to change all the columns that have type REAL to

> FLOAT?

The SQL data type REAL is the same as FLOAT(24). Thus, you don't have to

change your table definition and you test for SQL_TYP_FLOAT (and

SQL_TYP_NFLOAT for not-nullable columns). But because FLOAT can also be

used for double-precision numbers, you tave to use the "sqllen" attribute

to determine whether the C/C++ data type needs to be "float" or "double"

like this:

switch (sqlda->sqlvar[i].sqltype) {

case SQL_TYP_FLOAT:

case SQL_TYP_NFLOAT:

if (sqlda->sqlvar[i].sqllen == 4) {

// REAL

rowBufferSize += sizeof(float);

}

else {

// DOUBLE

rowBufferSize += sizeof(double);

}

break;

--

Knut Stolze

Information Integration

IBM Germany / University of Jena

Is there SQL_TYP_REAL in UDB V8.1?

Hi,

I'm using SQLDA to fetched a row of data and then get values of each

column, and I'm using sqltype (sqlDA->sqlvar[i].sqltype) to decide how

to cast the corresponding sqldata (sqlDA->sqlvar[i].sqldata), but

there seem to be no SQL_TYP_REAL defined. If so, why there is this

data type for defining the table schema? Now all columns that are

defined as REAL cannot be converted correctly. Is there a way to go

around this or I have to change all the columns that have type REAL to

FLOAT?

Thanks.

Re: Is there SQL_TYP_REAL in UDB V8.1?

Knut Stolze <stolzede.ibm.com> wrote in message news:<bf3gcn$pp$1fsuj29.rz.uni-jena.de>... Quote:

> minjie <minjieexcite.com> wrote:

>

Quote:

> > Hi,

> > I'm using SQLDA to fetched a row of data and then get values of each

> > column, and I'm using sqltype (sqlDA->sqlvar[i].sqltype) to decide how

> > to cast the corresponding sqldata (sqlDA->sqlvar[i].sqldata), but

> > there seem to be no SQL_TYP_REAL defined. If so, why there is this

> > data type for defining the table schema? Now all columns that are

> > defined as REAL cannot be converted correctly. Is there a way to go

> > around this or I have to change all the columns that have type REAL to

> > FLOAT?

>

> The SQL data type REAL is the same as FLOAT(24). Thus, you don't have to

> change your table definition and you test for SQL_TYP_FLOAT (and

> SQL_TYP_NFLOAT for not-nullable columns). But because FLOAT can also be

> used for double-precision numbers, you tave to use the "sqllen" attribute

> to determine whether the C/C++ data type needs to be "float" or "double"

> like this:

>

> switch (sqlda->sqlvar[i].sqltype) {

> case SQL_TYP_FLOAT:

> case SQL_TYP_NFLOAT:

> if (sqlda->sqlvar[i].sqllen == 4) {

> // REAL

> rowBufferSize += sizeof(float);

> }

> else {

> // DOUBLE

> rowBufferSize += sizeof(double);

> }

> break;

Many thanks.

Minjie