From: | Bastian Voigt <bastian(at)voigt(dot)in-berlin(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | PQSQL - binary data question |
Date: | 2004-10-29 12:09:37 |
Message-ID: | 200410291409.37659.bastian@voigt.in-berlin.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hallo List!
I just found this old posting on google. Now my question is how can I read an
integer value from the PGresult using the binary format? Can someone plz
gimme a code example? (please mail to me, because I have not subscribed to
the list)
Thanks a bunch! Now here's the old posting:
On Monday 27 October 2003 09:15, Tomasz Myrta wrote:
> Dnia 2003-10-27 00:08, UÅytkownik creid napisaÅ:
> > Problem: Assigning a COUNT(*) result into an integer variable in my C
> > program consistently fails except when I assign the same result to a char
> > variable. I can only assume that the internal data type the COUNT
> > function uses is integer.
> >
> > Can anyone help put me in the proper mindset so I may deal with this,
> > seemingly simple issue, to resolution.
> >
> > I need the integer result to to help me satisfy a dynamic memory
> > requirement... COUNT(*) result will tell me how many rows of data I need
> > to malloc and I cannot perform a math operation on a char variable.
>
> All libpq results are strings.
> some_int_value=atoi(PQgetvalue(...))
Not true anymore with protocol v3, which added the binary format. Text format
is still the default.
> Anyway why do you need count(*) ? When you retrieve your rows, you can
> always check how many are them using PQntuples(...) and then malloc your
> memory tables.
>
> Regards,
> Tomasz Myrta
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Hallgren | 2004-10-29 12:56:15 | Question regarding the mailing list. |
Previous Message | Thomas Hallgren | 2004-10-29 12:07:07 | Re: Reasoning behind process instead of thread based |