Re: Default values in functions

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Default values in functions
Date: 2021-12-29 23:34:37
Message-ID: CAKFQuwb4peZMzcsBnDj24Y0jRvPprfoebnP9+j9kuv9wL92xmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, December 29, 2021, Michael Lewis <mlewis(at)entrata(dot)com> wrote:
>
>
> If I can somehow pass "use default for this parameter" to functions like I
> can for insert statements, then that would be great to know.
>
>
There is not.

>
> Generally, the use case I am looking at is having a function with a few
> required parameters leading and then many optional and I'd like to ensure
> the optional ones get the default set if a value is used that "is not
> distinct from null" basically.
>
>
That isn’t how it works. Absence is what is important. Null is not
absence. As you showed, if you want nulls to be converted to defaults you
can use coalesce.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2021-12-30 00:17:18 Re: Default values in functions
Previous Message Tom Lane 2021-12-29 23:31:04 Re: Default values in functions