Re: Function with default value?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel CAUNE <d(dot)caune(at)free(dot)fr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Function with default value?
Date: 2006-01-29 15:47:57
Message-ID: 1793.1138549677@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Daniel CAUNE <d(dot)caune(at)free(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Daniel CAUNE 2006-01-29 20:15:21 Function with default value?
Previous Message Kashmira Patel (kupatel) 2006-01-28 06:48:22 Re: Question about check constraints