Re: Default values in functions - Mailing list pgsql-general

From David G. Johnston
Subject Re: Default values in functions
Date
Msg-id CAKFQuwb4peZMzcsBnDj24Y0jRvPprfoebnP9+j9kuv9wL92xmg@mail.gmail.com
Whole thread Raw
In response to Default values in functions  (Michael Lewis <mlewis@entrata.com>)
Responses Re: Default values in functions  (Michael Lewis <mlewis@entrata.com>)
List pgsql-general
On Wednesday, December 29, 2021, Michael Lewis <mlewis@entrata.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.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Default values in functions
Next
From: Michael Lewis
Date:
Subject: Re: Default values in functions