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 1vSnhu-005yTP-38 for pgsql-general@arkaria.postgresql.org; Tue, 09 Dec 2025 02:44:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vSnht-002O03-24 for pgsql-general@arkaria.postgresql.org; Tue, 09 Dec 2025 02:44:05 +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 1vSnht-002Nzv-0y for pgsql-general@lists.postgresql.org; Tue, 09 Dec 2025 02:44:05 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vSnhr-003xca-1l for pgsql-general@lists.postgresql.org; Tue, 09 Dec 2025 02:44:05 +0000 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-45358572a11so2944870b6e.3 for ; Mon, 08 Dec 2025 18:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765248242; x=1765853042; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=nyjlFSpgMRo7PIVjrxGAavoc2/fGzscYeyQZCgLV1pI=; b=kHwhLlc7P3p6ztQ5mQlWFUHVlr7WrkYKOE6XZ+unWxfF9T2MxcVhX5qmo7ud0403c8 pZOz/NrgB0hKaMKByTjC6FamiPK+eEwH0CrX/fB3trVaiQGIyGv10+eYynEB7cV+NY9/ GWR49nHILuFXyiWMXIHjLMxZx3PLACETAtvtyqZOXICxH1uLrkIqURABad3MVHw4Wvzk zCxXnqvZkFKwOn4rOng7C5gkYjNdDdCciG0roYVf1ZmswNZlqEzY0EUN5XX3NMXdJku/ LsT1ABLKgrf/oDCm7nGe2gVu2AtxBP1Fo1lztOotRgx6Y8CnIlENiXyP0KcFLQHH7OZE q44Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765248242; x=1765853042; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nyjlFSpgMRo7PIVjrxGAavoc2/fGzscYeyQZCgLV1pI=; b=hxIzOhaoeHbYnXyMyAfv61H3uX4C2Zc6KweOoueT1kZn/GZieUX7GD3ZTkgWaJDEdS 2pKA49krIrbWh4jbOpf5fQ1dJTrgcwCUVK40GYQosVjqYUx2Qum/spYh6qTFXJQw1rTY 5tCB8u7Bl44yM2zSfI83JBhUFyeZPFmbnWqZ5Jnb4B5weqZaBL+41CS9tmXsEE+/XRqw I9kCrfTO+aetZSBjOjfgTH6JyYnMFt03FZMNOPVE0+1Q6fdUcijanjPLaQmqAn6XDndO KxP5Zrxe4YqPpsAfQBu0Hd3V8MRL2bMIWE8PY6lcJOiH02zpZvUv6VvtHPvV85ErbwLW jcZQ== X-Gm-Message-State: AOJu0YwtOetqtPQ8gU/T7EZq9Lw2VQQ452kSa8sCUGkEIC7+fyM0yBF7 9VFp0JTsAh4Di+wKiac58yX+WkiSuukvOXNbk0n7mzi+Hhv+SUlKDstyIgaEIbJVL9dY57INM7z rA2AA7mo1ACsEf2LImaCbz6sqOv1YQDs= X-Gm-Gg: ASbGncscyAbDpNTECLg4BMPCctb7hmjgeTkaLLooHvHkhpZOblaigvHID3IIb+TWFWt gJA2IitPNM8FffrLMJU2xkYny0EwkBg+Y9rp+MUoAgdejgdIrAJ9pQCaqsNrdwGw/GcZ47zdKcC qFrherzQPEW5L4i9MXlztam67SHoTl2p4XKQ3z83lK7C+xVycb0qgK4snTeNumMrqeRxakIPwXL 9IyoWdKo64yAmh5TStGyHWuDabBnldEHY/eCKqXqMlRdwyEcB1bEK9aXoSvVwzjdsSbXA== X-Google-Smtp-Source: AGHT+IHHzq5dmToUY/qidtwtnozGNGbEUdnfAu6YqpLK+zwkP2ci8FGadNUUiMFGdIihOoFKWYgLC6mNEprb0+7hRi8= X-Received: by 2002:a05:6808:2213:b0:441:8f74:fce with SMTP id 5614622812f47-4539e0c1e81mr4677584b6e.59.1765248241760; Mon, 08 Dec 2025 18:44:01 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:6802:2d82:20b0:605:7eb8:cb20 with HTTP; Mon, 8 Dec 2025 18:44:01 -0800 (PST) In-Reply-To: References: From: "David G. Johnston" Date: Mon, 8 Dec 2025 19:44:01 -0700 X-Gm-Features: AQt7F2pRNSt8O6KOCHTeq8ZB4-XKjUmL2CYTeJXihOSe-Kxvgen7ZQMacn2R77Y Message-ID: Subject: Re: How do I check for NULL To: Igor Korot Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000063fd2a06457be22d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000063fd2a06457be22d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, December 8, 2025, Igor Korot wrote: > > > However,, I'd like to still insert the record and I'd like to do somethin= g > 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. David J. --00000000000063fd2a06457be22d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, December 8, 2025, Igor Korot <ikorot01@gmail.com> wrote:

However,, I'd like to still insert the record and I'd like to do so= mething like:

INSERT INTO test VALUES( 0, 'abc', 12345, IF( (SELECT foo FROM bar)= =3D=3D
NULL, "postgres", <select_result>), /*more data follow*/);<= br>
What would be the best way to achieve this?

The =E2=80=9Ccoalesce=E2=80=9D function.

David J.
=C2=A0
--00000000000063fd2a06457be22d--