pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel CAUNE <d.caune@free.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: Function with default value?
Date: Sun, 29 Jan 2006 10:47:57 -0500
Message-ID: <1793.1138549677@sss.pgh.pa.us> (raw)
In-Reply-To: <0ITV004G911MRG90@VL-MH-MR002.ip.videotron.ca>
References: <0ITV004G911MRG90@VL-MH-MR002.ip.videotron.ca>

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



view thread (3+ messages)  latest in thread

Message-ID: <1793.1138549677@sss.pgh.pa.us>
Permalink:  ../1793.1138549677@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1793.1138549677@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, d.caune@free.fr
  Subject: Re: Function with default value?
  In-Reply-To: <1793.1138549677@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox