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.94.2) (envelope-from ) id 1r0mNp-007nDy-2U for pgsql-sql@arkaria.postgresql.org; Wed, 08 Nov 2023 17:30:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r0mNn-006Lka-N9 for pgsql-sql@arkaria.postgresql.org; Wed, 08 Nov 2023 17:30:27 +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.94.2) (envelope-from ) id 1r0mNn-006LkS-EZ for pgsql-sql@lists.postgresql.org; Wed, 08 Nov 2023 17:30:27 +0000 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r0mNl-004bGm-0X for pgsql-sql@lists.postgresql.org; Wed, 08 Nov 2023 17:30:26 +0000 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5842a94feb2so3916845eaf.0 for ; Wed, 08 Nov 2023 09:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699464624; x=1700069424; 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=/Z2s/1uS96hJQzN19uk5NZXHAa4aGC1puW3SeNJ1kuA=; b=Wenc+qmQ1Vsb2bd0cDzs2ZDi4080ojx6TMkWB7rOzKWrFGmDC1FA28yu4ZOVjfWl5d 2BYWkzIF8wCEEN6Y5vOaR7iuKldFcxZGb2TLBoyGpuAtMiOzny975q2gRGc0wK1IU9pb UlQmzTN625Dzd7lGP5Jy1dlvS5qJ0aBd3zi2Xa8NHplUCb8QvCM4NZU369kP6tKlrjXR +Czh77z7ZCBpTz6x88uMRx0Zs91VRsZAjAIuD5ga2yGd383kMJ5uCErdb+Hylr6v/Y54 kxrQdHRtlg9tSt+nSGrg9IHVMGYvNJ7rn0f0cfQlFA+lJbVcYnSkjLohbtIK9F2ZmL01 ilVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699464624; x=1700069424; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Z2s/1uS96hJQzN19uk5NZXHAa4aGC1puW3SeNJ1kuA=; b=AMyxvasi1tlPDBYOOTVVV3adu/rmZfod5ohEcUz86FanBwixHCPlWuPXsuxvNGbdDd x7jL0HHcueyqR3ufM22ucaPl1kZQ2Up3aeEklmFussrVrVBuH5JS8SEdSCQucaMbNhsi ujR4HCrHqHsHdgw+Rm8zu8c36MzJIAVai337Yo8Dmy3cUgYKC+CZg7YCZVq6nNFqsQ0n 5XDgC0M31DdQNKRtVSRoo9S4vKf4sP3MYME+3uruPS10xxHv120qXI7Zo3WqAN0XnSvD ja1xBouR5g7MYavpVDUjuQ6oH8BigCPTFvz8YSSlr7zVkYknA9jR3MQKyPPV3mX2RxTI ehLg== X-Gm-Message-State: AOJu0Yz2CCbCspqPd03UEc+1WVmrq4zKBsaeh4/ufkCrB9f9R8JzdCAZ U8H6ShQrN4tlr7J/q9nRDwD9hyWabQNgIQE3JyY= X-Google-Smtp-Source: AGHT+IG/1FgCg/NVSXVX4vmox2JMlBKiQyMQgwciCrFUjKS1Weqqjcv5JPGSDph/+8CUgS87mtO7dZ0Yi8T5IL48U80= X-Received: by 2002:a4a:d357:0:b0:581:6a56:f3bf with SMTP id d23-20020a4ad357000000b005816a56f3bfmr2434136oos.5.1699464624296; Wed, 08 Nov 2023 09:30:24 -0800 (PST) MIME-Version: 1.0 Received: by 2002:ac9:5989:0:b0:4f6:384b:17ef with HTTP; Wed, 8 Nov 2023 09:30:23 -0800 (PST) In-Reply-To: References: From: "David G. Johnston" Date: Wed, 8 Nov 2023 10:30:23 -0700 Message-ID: Subject: Re: DEFAULT in update & prepared statements To: Sanjay Minni Cc: "pgsql-sql@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000003d58b30609a77133" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003d58b30609a77133 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wednesday, November 8, 2023, David G. Johnston < david.g.johnston@gmail.com> wrote: > On Wednesday, November 8, 2023, Sanjay Minni > wrote: > >> Can DEFAULT (defined for a timestamp column as now() ) be used in >> 1. prepared statement i.e. EXECUTE ( ..., DEFAULT, ...) >> 2. in an UPDATE statement UPDATE TABLE SET update_time =3D DEFAULT .. >> > > 5 seconds looking at the syntax for update in the docs answers the second > question. > > The first question doesn=E2=80=99t really make sense - but regardless of = what you > are trying to communicate there just try it. If the result you get doesn= =E2=80=99t > make sense post what you tried. > As the docs do not show DEFAULT for execute the answer is indeed no for the first question. Default behaves as syntax for the query and syntax, like identifiers, cannot be parameterized. David J. --0000000000003d58b30609a77133 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wednesday, November 8, 2023, David G. Johnston <david.g.johnston@gmail.com> wrote:<= br>
On Wednesday, November 8, 2023, Sanjay Mi= nni <sanjay.= minni@gmail.com> wrote:
Can DEFAULT (defined for a timestamp column as now() ) be used in
=
1. pr= epared statement i.e. EXECUTE ( ..., DEFAULT, ...)
2. in an UPDATE state= ment=C2=A0 UPDATE TABLE SET update_time =3D DEFAULT ..

5 seconds looking at the syntax for update in the d= ocs answers the second question.

The first questio= n doesn=E2=80=99t really make sense - but regardless of what you are trying= to communicate there just try it.=C2=A0 If the result you get doesn=E2=80= =99t make sense post what you tried.

= As the docs do not show DEFAULT for execute the answer is indeed no for the= first question.=C2=A0 Default behaves as syntax for the query and syntax, = like identifiers, cannot be parameterized.

David J= .

--0000000000003d58b30609a77133--