Professional Web Applications Themes

Is there SQL_TYP_REAL in UDB V8.1? - IBM DB2

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....

  1. #1

    Default 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.
    minjie Guest

  2. #2

    Default Re: Is there SQL_TYP_REAL in UDB V8.1?

    minjie <minjieexcite.com> wrote:
    > 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
    Knut Stolze Guest

  3. #3

    Default 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.
    minjie Guest

  4. #4

    Default 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>...
    > minjie <minjieexcite.com> wrote:
    >
    > > 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
    minjie Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139