libpq: PQexecParams, binaryFormat and float

Поиск
Список
Период
Сортировка
От Sun, Way
Тема libpq: PQexecParams, binaryFormat and float
Дата
Msg-id 7FBC16D72C0ABF45A88EAEB9ED3464C48CC172@sausatlexch01.corp.sa.net
обсуждение исходный текст
Ответы Re: libpq: PQexecParams, binaryFormat and float  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: libpq: PQexecParams, binaryFormat and float  (Richard Frankland <rfrankla@yahoo.com>)
Список pgsql-interfaces

Hi,

I'm having trouble inserting a float into pg using binary format.

Hope someone on the list can help me point out what I'm doing wrong....

    float    loadavg;

    loadavg = htonl(1.23);

    paramValues[0] = (char *) &loadavg
    paramLengths[0] = sizeof(loadavg);
    paramFormats[0] = 1;       

    res = PQexecParams(conn,
                       "INSERT INTO cpu (loadavg) VALUES ($1::real)",
                       1,       
                       NULL,    
                       paramValues,
                       paramLengths,
                       paramFormats,
                       1);     

From psql, select returns the value as 1.20765e-38 instead of 1.23.....:(

Thanks

Way


      - - - - - Appended by Scientific Atlanta, a Cisco company - - - - -         
This e-mail and any attachments may contain information which is confidential,
proprietary, privileged or otherwise protected by law. The information is solely
intended for the named addressee (or a person responsible for delivering it to
the addressee). If you are not the intended recipient of this message, you are
not authorized to read, print, retain, copy or disseminate this message or any
part of it. If you have received this e-mail in error, please notify the sender
immediately by return e-mail and delete it from your computer.

В списке pgsql-interfaces по дате отправления:

Предыдущее
От: René Grün
Дата:
Сообщение: NAN-Values in ECPG-Code
Следующее
От: Tom Lane
Дата:
Сообщение: Re: libpq: PQexecParams, binaryFormat and float