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 1vT0Ho-00B8Hy-2T for pgsql-general@arkaria.postgresql.org; Tue, 09 Dec 2025 16:10:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vT0Hn-005HC0-0M for pgsql-general@arkaria.postgresql.org; Tue, 09 Dec 2025 16:09:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vT0Hm-005HBs-0A for pgsql-general@lists.postgresql.org; Tue, 09 Dec 2025 16:09:59 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vT0Hj-0044Nu-08 for pgsql-general@lists.postgresql.org; Tue, 09 Dec 2025 16:09:57 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id AD712EC0629; Tue, 9 Dec 2025 11:09:52 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 09 Dec 2025 11:09:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1765296592; x=1765382992; bh=I1wWAUwS89dFDwxZOMrwnujJHVzzPPWzCUQsYUDwvcY=; b= MkdJhoPepNUZ5OspwrkQt1ukeKDg9AkclMqLFPgLp70E1U3SOxku69zAWaKYKUgF CCkMNnqqxbOpitZDD+xIssW/ksj2Z01vT7MPExcNJq3Yn+iXqFhzZSi6pcxuqDTA nIba+jG5uLJPu0gfhqT8pZL8nGGf2qZ8onNCwd77MD7OY8MD9ERWlR/ia613zdMO fwotAVhp7dHqhMcoauZP98yGKB3BDNqQybEVTUEjlvnh6LZmYULYHIGpgdqSUukv HtROOOTDUVIg7aH0y8lA5EuYAkN+ju+gJbhX0f+68uvOI4tOg5UDdSA45elFf4VJ 4/t986TVTo5ht1kw+cSNyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1765296592; x= 1765382992; bh=I1wWAUwS89dFDwxZOMrwnujJHVzzPPWzCUQsYUDwvcY=; b=P ixr4LibGRnVL9STh9GpSfhyq/VHZo3pHK48YWXGnyR7meL2/0e4O3PLzWoeO3Jjb jB76iKMrbBGzkJRi3kr5ih00XriPCZpY+u2j0WQ8TBaIcqwEloz5LxIMluP6Et06 QIn60cDhBlH8sXGT1SfKPhwsgJbgghj6NKMiSoiLC/19LGE0R1Q43MRD3E4I/r/1 4xJNlJgOS+Pwv/Ls9XiM2Va+aDEeLMKNQgI27bPbjQBbUKt/P3AqN2OB2od/HLi6 jqbDO5F5PrxfOwuknVoQze3E8VA/5iQWKBgvclGdXnRetEB27xYKlJrRtJ9TIdb7 /Y2ikXJ1kNEC0DErpvirQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvtddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpefgudefkefhveefleevieeuveehvdduudekuddvvdelhfeu ueeijedtuedvvedvueenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepfedpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepihhkohhrohhttddusehgmhgrihhlrdgtohhm pdhrtghpthhtohepuggrvhhiugdrghdrjhhohhhnshhtohhnsehgmhgrihhlrdgtohhmpd hrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghs qhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Dec 2025 11:09:52 -0500 (EST) Message-ID: <2d6f7410-433e-48a6-85b5-dd29d12bcf61@aklaver.com> Date: Tue, 9 Dec 2025 08:09:51 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How do I check for NULL To: Igor Korot , "David G. Johnston" Cc: "pgsql-generallists.postgresql.org" References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/8/25 23:53, Igor Korot wrote: > Hi, Davd, > > On Mon, Dec 8, 2025 at 6:44 PM 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 something like: >>> >>> INSERT INTO test VALUES( 0, 'abc', 12345, IF( (SELECT foo FROM bar) == >>> NULL, "postgres", ), /*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,std::allocator >> Read: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS > > Thank you. >> >> David J. >> > > -- Adrian Klaver adrian.klaver@aklaver.com