libpq: Char to INT

Started by Nelio Alves Pereira Filhoover 25 years ago4 messagesgeneral
Jump to latest

Hi there..

I want to do a query that returns an integer and then fetch the result
as an int. My query is something like that:

SELECT 1::int

Normally, I would get the result as a char and then convert it to int.
Until here, no misteries. However, 'The Programmer's Guide' shows an
example where a char pointer is converted to an int pointer, and then
it's used normally. I tried that, but the result wasn't correct..

Just to mention, I 'm used to convert char to int with strtol.

Thanks in advance.

Nelio Pereira
IFX Networks

#2Jim Mercer
jim@reptiles.org
In reply to: Nelio Alves Pereira Filho (#1)
Re: libpq: Char to INT

On Thu, Nov 09, 2000 at 02:03:47PM -0200, Nelio Alves Pereira Filho wrote:

I want to do a query that returns an integer and then fetch the result
as an int. My query is something like that:

SELECT 1::int

Normally, I would get the result as a char and then convert it to int.
Until here, no misteries. However, 'The Programmer's Guide' shows an
example where a char pointer is converted to an int pointer, and then
it's used normally. I tried that, but the result wasn't correct..

Just to mention, I 'm used to convert char to int with strtol.

i generally do:

int num;

num = atoi(PQgetvalue(query_ptr, recnum, fnum));

--
[ Jim Mercer jim@reptiles.org +1 416 410-5633 ]
[ Reptilian Research -- Longer Life through Colder Blood ]
[ Don't be fooled by cheap Finnish imitations; BSD is the One True Code. ]

#3Mark Lane
mlane@mynewthing.com
In reply to: Nelio Alves Pereira Filho (#1)
Usogres

Can someone give me an idea of exactly what usogres does? I went to the
english site but I am not clear on what exactly it does.

Mark

#4Hosokawa Tetsuichi
hosokawa@good-day.co.jp
In reply to: Mark Lane (#3)
Re: Usogres

Hi!

Sorry, my english is very poor so you cannot understand it.

On Thu, 9 Nov 2000 09:53:22 -0700
"Mark Lane" <mlane@mynewthing.com> wrote:

Can someone give me an idea of exactly what usogres does? I went to the
english site but I am not clear on what exactly it does.

Someone help me?
I need translator who understands my Japanese.

Thank you.
--
* Hosokawa Tetsuichi
* hosokawa@good-day.co.jp