Re: DEFAULT in update & prepared statements

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Sanjay Minni <sanjay(dot)minni(at)gmail(dot)com>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: DEFAULT in update & prepared statements
Date: 2023-11-08 17:30:23
Message-ID: CAKFQuwYK9OqAqN9DzFqK9=kaU_rxxFQWFsxTaKdLpsM0VH6SJg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wednesday, November 8, 2023, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Wednesday, November 8, 2023, Sanjay Minni <sanjay(dot)minni(at)gmail(dot)com>
> 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 = DEFAULT ..
>>
>
> 5 seconds looking at the syntax for update in the docs answers the second
> question.
>
> The first question doesn’t really make sense - but regardless of what you
> are trying to communicate there just try it. If the result you get doesn’t
> 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Schmidlechner 2023-11-24 19:23:44 Bad execution plan when joining partitioned tables
Previous Message David G. Johnston 2023-11-08 17:21:20 Re: DEFAULT in update & prepared statements