[NOOB] try tu put a number with pqexecprepare

Started by elekisover 17 years ago9 messagesgeneral
Jump to latest
#1elekis
elekis@gmail.com

hi,

I try to use postgresql with a simple example using parameter, (so
with pqprepare and pqexecprepare).
I have trouble to put number.

I put the code here

http://pastebin.com/m1860cc27

I symply try to put the number 5 for the second column, and after that
read the line.

but the database, I have taht
83886080 in place of 5.

any idea??

PS: the oid come from the pg_type.h but if I include that in the file
I have a error with the node.h (dunno why)

thanks

a++

--
http://deathboater.blogspot.com/

#2Daniel Verite
daniel@manitou-mail.org
In reply to: elekis (#1)
Re: [NOOB] try tu put a number with pqexecprepare

elekis wrote:

I put the code here

http://pastebin.com/m1860cc27

I symply try to put the number 5 for the second column, and after

that

read the line.

but the database, I have taht
83886080 in place of 5.

83886080 happens to be ntohl(5), it's probably not a coincidence :)

Since you're using binary format for your integer parameters, you must
convert them from host byte order to network byte order with htonl()
and conversely use ntohl() for results.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org

#3elekis
elekis@gmail.com
In reply to: Daniel Verite (#2)
Re: [NOOB] try tu put a number with pqexecprepare

hi, and thanks

something, I don't underdstand, a little research on google say to me
that htonl and...is in

#include <arpa/inet.h> a network stuff is that normal that I have to
use that???

I just wanna put number in the db.(sniff)

thanks

a++

On Fri, Nov 28, 2008 at 11:23 AM, Daniel Verite <daniel@manitou-mail.org> wrote:

elekis wrote:

I put the code here

http://pastebin.com/m1860cc27

I symply try to put the number 5 for the second column, and after

that

read the line.

but the database, I have taht
83886080 in place of 5.

83886080 happens to be ntohl(5), it's probably not a coincidence :)

Since you're using binary format for your integer parameters, you must
convert them from host byte order to network byte order with htonl() and
conversely use ntohl() for results.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

--
http://deathboater.blogspot.com/

In reply to: elekis (#3)
Re: [NOOB] try tu put a number with pqexecprepare

On 28/11/2008 10:40, elekis wrote:

I just wanna put number in the db.(sniff)

ROFOL!

I can't help you with your problem, but you've made my morning!

:-)

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

#5elekis
elekis@gmail.com
In reply to: Raymond O'Donnell (#4)
Re: [NOOB] try tu put a number with pqexecprepare

On Fri, Nov 28, 2008 at 11:48 AM, Raymond O'Donnell <rod@iol.ie> wrote:

On 28/11/2008 10:40, elekis wrote:

I just wanna put number in the db.(sniff)

ROFOL!

be my guess :D

by the way,

I use cl.exe (windows) and he say
Cannot open include file: 'netinet/in.h': No such file or directory

is there any options compiles?? or other include ??

thanks a lot .

a++

I can't help you with your problem, but you've made my morning!

:-)

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

--
http://deathboater.blogspot.com/

#6Serge Fonville
serge.fonville@gmail.com
In reply to: elekis (#5)
Re: [NOOB] try tu put a number with pqexecprepare

I symply try to put the number 5 for the second column, and after that

read the line.

I just wanna put number in the db.(sniff)

To put 5 in your database use either a text of numeric datatype for your
column.

I use cl.exe (windows) and he say

Cannot open include file: 'netinet/in.h': No such file or directory

To resolve the lack of 'netinet/in.h' on Windows, take a look at uwin,
gnuwin and libgw32c

Hope this helps.

Regards,

Serge Fonville

#7Serge Fonville
serge.fonville@gmail.com
In reply to: Serge Fonville (#6)
Re: [NOOB] try tu put a number with pqexecprepare

I simply try to put the number 5 for the second column, and after that

read the line.

I just wanna put number in the db.(sniff)

To put 5 in your database use either a text of numeric datatype for your
column.

I use cl.exe (windows) and he say

Cannot open include file: 'netinet/in.h': No such file or directory

To resolve the lack of 'netinet/in.h' on Windows, take a look at uwin,
gnuwin and libgw32c

Hope this helps.

Regards,

Serge Fonville

#8Daniel Verite
daniel@manitou-mail.org
In reply to: elekis (#5)
Re: [NOOB] try tu put a number with pqexecprepare

elekis wrote:

by the way,

I use cl.exe (windows) and he say
Cannot open include file: 'netinet/in.h': No such file or directory

is there any options compiles?? or other include ??

For windows, I'm using this:

#include <winsock2.h>

and it appears to be good enough.

You may have to include the winsock library in the link, too, if you
end up with missing symbols.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org

#9elekis
elekis@gmail.com
In reply to: elekis (#5)
Fwd: [NOOB] try tu put a number with pqexecprepare

---------- Forwarded message ----------
From: elekis <elekis@gmail.com>
Date: Fri, Nov 28, 2008 at 12:53 PM
Subject: Re: [GENERAL] [NOOB] try tu put a number with pqexecprepare
To: Daniel Verite <daniel@manitou-mail.org>

thanks for everything (and sorry for my english :D)

a++

On Fri, Nov 28, 2008 at 12:15 PM, Daniel Verite <daniel@manitou-mail.org> wrote:

elekis wrote:

by the way,

I use cl.exe (windows) and he say
Cannot open include file: 'netinet/in.h': No such file or directory

is there any options compiles?? or other include ??

For windows, I'm using this:

#include <winsock2.h>

and it appears to be good enough.

You may have to include the winsock library in the link, too, if you end up
with missing symbols.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

--
http://deathboater.blogspot.com/

--
http://deathboater.blogspot.com/