Re: Function with default value? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Function with default value?
Date
Msg-id 1793.1138549677@sss.pgh.pa.us
Whole thread Raw
In response to Function with default value?  (Daniel CAUNE <d.caune@free.fr>)
Responses Re: Function with default value?  (Daniel CAUNE <d.caune@free.fr>)
List pgsql-sql
Daniel CAUNE <d.caune@free.fr> writes:
> Is it possible to define a function with some default values?
> CREATE OR REPLACE FUNCTION foo(i IN int, j IN int DEFAULT := 1)

No.  But you can fake many versions of this with a family of functions:

CREATE OR REPLACE FUNCTION foo(i IN int, j IN int) ...

CREATE OR REPLACE FUNCTION foo(i IN int) ... return foo(i, 1) ...

Remember that PG lets you "overload" a function name by using the same
name with different parameter lists.
        regards, tom lane


pgsql-sql by date:

Previous
From: Daniel CAUNE
Date:
Subject: Function with default value?
Next
From: Daniel CAUNE
Date:
Subject: Re: Function with default value?