Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSsXH-0081Jv-1r for pgsql-general@arkaria.postgresql.org; Tue, 09 Dec 2025 07:53:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vSsXG-003g6i-0J for pgsql-general@arkaria.postgresql.org; Tue, 09 Dec 2025 07:53:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSsXF-003g6a-2T for pgsql-general@lists.postgresql.org; Tue, 09 Dec 2025 07:53:26 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vSsXD-003tVb-2N for pgsql-general@lists.postgresql.org; Tue, 09 Dec 2025 07:53:25 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-787c9f90eccso52266777b3.3 for ; Mon, 08 Dec 2025 23:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765266803; x=1765871603; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=POCqTg87JhGxGKdkjnVxh5eZLXMVEq9SpB5aXZHc+mE=; b=iT2ikHPYDb4bcwVRH+6wrMIZ21H+XwZPttbR4i2Lk1bW412NQ9/a7dUNxoScF9ac47 LF8CYA32OeIQ1qhZ1x6a4NoKnyQyTmpIolDG+sYRk5Lul65K3RNi350nDkGo2sd0Cyi0 MWMe+TLZONSVe3noRTMx1DBs+kerEPKjyljDFAQw+LsqqTX7aVTwTkNbuaZExdEzlIad ptmQUVA8jKmgpKTYoiNctlx5FSSkJZYyVlzcegjGORejYNtKT2rfrjEP3DySEYVsr8yl lup5S0ats/0MGU+OJiLk6iU7ZoRs2txrjjZ/gJ04mVwrq0KSyFFKgQgOWP8Qq6PWwt4G wPlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765266803; x=1765871603; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=POCqTg87JhGxGKdkjnVxh5eZLXMVEq9SpB5aXZHc+mE=; b=AECI3auhpcmUpZvcKVv07cUWZVbi8JFoFyz5KhF5N8xNLXq5cnT/Q8EbnGPjuGc0kH 39BwX3Efb0zhhogJMG7d6U4kDPNqKNyNETX895cK2t4wwCO2OolXZJbpRwZrPINe30gd Y09/LcByIXu4Etwk/VFUR+RcI2065W8P0myLpstoLvHfqgzubfXHQtbf6nTOaj5QGHgw AWRUxiz/rwTnBDU5nZo7zW1XOuk0GU8HwLj8HPfmFqgDukxs8+vwTVaNM13zHdVRPIMp Hh6sKjwxQ6bmO+JlVA/GVFBT+SyWa1pyhdad6ctpzqyVEK1z/Ei1RdpWrBG37zbFNv9F 5k7Q== X-Gm-Message-State: AOJu0YzkLPvHE/ViTSoaVcfVPkMiR+PcUgM5pbKn8EBPxdnyHnx3DO0C 9EUXYttRqcwjWtYqPFK3j/T1+OtKdEgV8ie0LdtTSq260xi4eGo1DunW6iVHf4XlWTZOu7CUe1B Jq2i8cYz1azrr/1crcvdH4oPvLv4O4r8= X-Gm-Gg: AY/fxX4hhaAbnU5VfHMBxqEmqeONRj6sF3LU2CXPNAx/N0xUCpWKp4DX8jZSWtxkmU8 7nMSaH1HtPx+w582ZXRPNEUqU4ToRgxCKgTG2lUIedsDJ6e2QqJhEld4LgPzv62XkwkF9fZN93c r4uUoGUBiQGZoFv4ZlKcQLCVt52rEZaYygYVS+5k0Q1St0/4ph8wfvcE7vQ7Ngor4s1BhQB71Y3 VohFDzSxXcKLrhkAU990oQe4BM621PpwukGg/kPIA6zb+IfCeqOMYnLWv7vb8+2QZ2In8yRwlVc jJ/ND0DE++m3g2oODg6uREwcSDg= X-Google-Smtp-Source: AGHT+IEpW/HuqrJZiQshojTvlHb+8S5FcTNhso1/88NaxDqyhtPNu90+esylqSIaoA6fchQuglxf7EXToD/k2fHIHoM= X-Received: by 2002:a05:690c:f91:b0:786:504a:4fe7 with SMTP id 00721157ae682-78c33cd10abmr100363417b3.67.1765266803675; Mon, 08 Dec 2025 23:53:23 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Igor Korot Date: Mon, 8 Dec 2025 23:53:08 -0800 X-Gm-Features: AQt7F2rLLpbH2bTtrFVDtt-m9SpVMiracg0kvEInQjJ0dPcMLx94CBlozLsBlkU Message-ID: Subject: Re: How do I check for NULL To: "David G. Johnston" Cc: "pgsql-generallists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Davd, On Mon, Dec 8, 2025 at 6:44=E2=80=AFPM David G. Johnston wrote: > > On Monday, December 8, 2025, Igor Korot wrote: >> >> >> However,, I'd like to still insert the record and I'd like to do somethi= ng like: >> >> INSERT INTO test VALUES( 0, 'abc', 12345, IF( (SELECT foo FROM bar) =3D= =3D >> NULL, "postgres", ), /*more data follow*/); >> >> What would be the best way to achieve this? > > > The =E2=80=9Ccoalesce=E2=80=9D function. This is the query I use for my ODBC calls: qry2 =3D L"INSERT INTO \"test\" VALUES( ?, ?, (SELECT c.oid FROM pg_class c, pg_namespace nc WHERE nc.oid =3D c.relnamespace AND c.relname =3D ? AND nc.nspname =3D ?), COALESCE((SELECT tableowner FROM pg_tables WHERE tablename =3D ? AND schemaname =3D ?), \"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,std::allocat= or > Thank you. > > David J. >