public inbox for [email protected]
help / color / mirror / Atom feedFrom: Igor Korot <[email protected]>
To: David G. Johnston <[email protected]>
Cc: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: How do I check for NULL
Date: Mon, 8 Dec 2025 23:53:08 -0800
Message-ID: <CA+FnnTye9NG93Bdp02qKcaKgdOzEMazhs9DNxZ8DMw9mcRXHjA@mail.gmail.com> (raw)
In-Reply-To: <CAKFQuwa0QT01k7yVQJOQ2oMeQQWOQ+NSeYYyY3-8sqNYLQvBOA@mail.gmail.com>
References: <CA+FnnTw=18Rba2XgceRUFKQo5P7Xf9QhXT6wKF=DgzYT6K9-sw@mail.gmail.com>
<CAKFQuwa0QT01k7yVQJOQ2oMeQQWOQ+NSeYYyY3-8sqNYLQvBOA@mail.gmail.com>
Hi, Davd,
On Mon, Dec 8, 2025 at 6:44 PM David G. Johnston
<[email protected]> wrote:
>
> On Monday, December 8, 2025, Igor Korot <[email protected]> wrote:
>>
>>
>> However,, I'd like to still insert the record and I'd like to do something like:
>>
>> INSERT INTO test VALUES( 0, 'abc', 12345, IF( (SELECT foo FROM bar) ==
>> NULL, "postgres", <select_result>), /*more data follow*/);
>>
>> What would be the best way to achieve this?
>
>
> The “coalesce” function.
This is the query I use for my ODBC calls:
qry2 = L"INSERT INTO \"test\" VALUES( ?, ?, (SELECT c.oid
FROM pg_class c, pg_namespace nc WHERE nc.oid = c.relnamespace AND
c.relname = ? AND nc.nspname = ?), COALESCE((SELECT tableowner FROM
pg_tables WHERE tablename = ? AND schemaname = ?), \"postgres\"), ...)
ON CONFLICT DO NOTHING;";
Calling SQLExecute after parameter binding results in
"L"ERROR: column \"postgres\" does not exist;\nError while preparing
parameters"std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>
Thank you.
>
> David J.
>
view thread (14+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: How do I check for NULL
In-Reply-To: <CA+FnnTye9NG93Bdp02qKcaKgdOzEMazhs9DNxZ8DMw9mcRXHjA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox