From: | Louis-David Mitterrand <cunctator(at)apartia(dot)ch> |
---|---|
To: | PGSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | detecting NULL column in SPI function |
Date: | 2000-09-28 15:05:31 |
Message-ID: | 20000928170531.A17373@styx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
In a SPI function I have this code snippet:
double startprice = *DatumGetFloat64(SPI_getbinval(
auction_tt->vals[i], auction_tt->tupdesc,
SPI_fnumber(auction_tt->tupdesc, "startprice"), &isnull));
To extract a value from the startprice column. It only works if
"startprice" is not NULL, otherwise the backend crashes.
In the provided example SPI functions I couldn't determine a good way of
testing for NULL on columns. Should I first try to return the Datum,
test it for NULL, then run DatumGetFloat64() on it? Isn't there a
simpler way?
Thanks in advance for your help, cheers,
--
Louis-David Mitterrand - ldm(at)apartia(dot)org - http://www.apartia.org
Hand, n.:
A singular instrument worn at the end of a human arm and
commonly thrust into somebody's pocket.
-- Ambrose Bierce, "The Devil's Dictionary"
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-09-28 15:20:55 | Re: detecting NULL column in SPI function |
Previous Message | Daryl Chance | 2000-09-28 15:02:16 | Talking with other Dbases. |