detecting NULL from libpq...

Started by dave maddenalmost 28 years ago2 messagesgeneral
Jump to latest
#1dave madden
dhm@paradigm.webvision.com

Hi. I'm wondering if it's possible to tell whether a field returned
by PQgetvalue() is NULL? Can one distinguish between a varchar field
that contains a string of zero length and a varchar field that is
NULL? (And if so, how? :-)

regards,
d.

#2Bruce Momjian
bruce@momjian.us
In reply to: dave madden (#1)
Re: [GENERAL] detecting NULL from libpq...

Hi. I'm wondering if it's possible to tell whether a field returned
by PQgetvalue() is NULL? Can one distinguish between a varchar field
that contains a string of zero length and a varchar field that is
NULL? (And if so, how? :-)

From man libpq:

PQgetisnull returns the NULL status of a field.
int PQgetisnull(PGresult *res,
int tup_num,
int field_num);

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)