Thread: [NOOB] try tu put a number with pqexecprepare

[NOOB] try tu put a number with pqexecprepare

From
elekis
Date:
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/

Re: [NOOB] try tu put a number with pqexecprepare

From
"Daniel Verite"
Date:
    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

Re: [NOOB] try tu put a number with pqexecprepare

From
elekis
Date:
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/

Re: [NOOB] try tu put a number with pqexecprepare

From
Raymond O'Donnell
Date:
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
------------------------------------------------------------------

Re: [NOOB] try tu put a number with pqexecprepare

From
elekis
Date:
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/

Re: [NOOB] try tu put a number with pqexecprepare

From
"Serge Fonville"
Date:
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

Re: [NOOB] try tu put a number with pqexecprepare

From
"Serge Fonville"
Date:
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

Re: [NOOB] try tu put a number with pqexecprepare

From
"Daniel Verite"
Date:
    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

Fwd: [NOOB] try tu put a number with pqexecprepare

From
elekis
Date:
---------- 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/