pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: Function with default value?
3+ messages / 2 participants
[nested] [flat]
* Function with default value?
@ 2006-01-29 20:15 Daniel CAUNE <d.caune@free.fr>
2006-01-29 15:47 ` Re: Function with default value? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Daniel CAUNE @ 2006-01-29 20:15 UTC (permalink / raw)
To: pgsql-sql
Hi,
Is it possible to define a function with some default values?
CREATE OR REPLACE FUNCTION foo(i IN int, j IN int DEFAULT := 1)
…
Anyway, I didn’t find such a feature described in the PostgreSQL 8.1 documentation, but sometimes, that doesn’t mean that the feature doesn’t exist! :-)
Thanks,
Daniel
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Function with default value?
2006-01-29 20:15 Function with default value? Daniel CAUNE <d.caune@free.fr>
@ 2006-01-29 15:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-01-30 03:40 ` Re: Function with default value? Daniel CAUNE <d.caune@free.fr>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2006-01-29 15:47 UTC (permalink / raw)
To: Daniel CAUNE <d.caune@free.fr>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Function with default value?
2006-01-29 20:15 Function with default value? Daniel CAUNE <d.caune@free.fr>
2006-01-29 15:47 ` Re: Function with default value? Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-01-30 03:40 ` Daniel CAUNE <d.caune@free.fr>
0 siblings, 0 replies; 3+ messages in thread
From: Daniel CAUNE @ 2006-01-30 03:40 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
> -----Message d'origine-----
> De : Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Envoyé : dimanche 29 janvier 2006 10:48
> À : Daniel CAUNE
> Cc : pgsql-sql@postgresql.org
> Objet : Re: [SQL] Function with default value?
>
> 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
Yes, thanks Tom, for the second time.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-01-30 03:40 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-29 20:15 Function with default value? Daniel CAUNE <d.caune@free.fr>
2006-01-29 15:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-01-30 03:40 ` Daniel CAUNE <d.caune@free.fr>
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