pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
libpq: NULL in binary parameters
2+ messages / 2 participants
[nested] [flat]

* libpq: NULL in binary parameters
@ 2007-05-17 16:48 john heasley <heas@shrubbery.net>
  2007-05-17 23:11 ` Re: libpq: NULL in binary parameters Andrew McNamara <andrewm@object-craft.com.au>
  0 siblings, 1 reply; 2+ messages in thread

From: john heasley @ 2007-05-17 16:48 UTC (permalink / raw)
  To: pgsql-interfaces

Using binary parameters with libpq (PQexecParams) I am having trouble
figuring out how NULL is represented since there does not appear to be
a NULLOID.

For example, if a table has a varchar column and it IS NULL for a given
row, then what I received is a zero-length string ("").  Also, while I
can insert a NULL varchar simply by setting the value to NULL (or 0), it
is not clear how to acheive this with say an integer column.  And, is it
possible to match NULL using a parameter.

I suspect this boils down to, how is NULL represented as a binary parameter?

clues?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: libpq: NULL in binary parameters
  2007-05-17 16:48 libpq: NULL in binary parameters john heasley <heas@shrubbery.net>
@ 2007-05-17 23:11 ` Andrew McNamara <andrewm@object-craft.com.au>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrew McNamara @ 2007-05-17 23:11 UTC (permalink / raw)
  To: john heasley <heas@shrubbery.net>; +Cc: pgsql-interfaces

>Using binary parameters with libpq (PQexecParams) I am having trouble
>figuring out how NULL is represented since there does not appear to be
>a NULLOID.
>
>For example, if a table has a varchar column and it IS NULL for a given
>row, then what I received is a zero-length string ("").  Also, while I
>can insert a NULL varchar simply by setting the value to NULL (or 0), it
>is not clear how to acheive this with say an integer column.  And, is it
>possible to match NULL using a parameter.

The arguments to PQexecParams are all pointers to buffers, even in the
case of ints. To send a NULL, simply pass a null pointer for that value.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-05-17 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-05-17 16:48 libpq: NULL in binary parameters john heasley <heas@shrubbery.net>
2007-05-17 23:11 ` Andrew McNamara <andrewm@object-craft.com.au>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox