libpq: PQexecParams, binaryFormat and float - Mailing list pgsql-interfaces

From Sun, Way
Subject libpq: PQexecParams, binaryFormat and float
Date
Msg-id 7FBC16D72C0ABF45A88EAEB9ED3464C48CC172@sausatlexch01.corp.sa.net
Whole thread Raw
Responses Re: libpq: PQexecParams, binaryFormat and float
Re: libpq: PQexecParams, binaryFormat and float
List 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 by date:

Previous
From: René Grün
Date:
Subject: NAN-Values in ECPG-Code
Next
From: Tom Lane
Date:
Subject: Re: libpq: PQexecParams, binaryFormat and float