From: Phil Endecott <spam_from_postgresql_sql@chezphil.org>
To: Pradeepkumar, Pyatalo (IE10) <Pradeepkumar.Pyatalo@honeywell.com>
To: pgsql-sql@postgresql.org
Subject: Re: Function Parameters - need help !!!
Date: Mon, 21 Jun 2004 07:52:48 -0400
Message-ID: <2733210@chezphil.org> (raw)
In-Reply-To: <77ED2BF75D59D1439F90412CC5B109740DCFBDCC@ie10-sahara.hiso.honeywell.com>
References: <77ED2BF75D59D1439F90412CC5B109740DCFBDCC@ie10-sahara.hiso.honeywell.com>
Hi,
Quote from Section 37.11 of the manual:
# There are no default values for parameters in PostgreSQL.
# You can overload function names in PostgreSQL. This is often used
to work around the lack of default parameters.
So for your example:
> CREATE FUNCTION test(integer,integer) RETURNS INTEGER AS '
> ...
you should be able to write:
CREATE FUNCTION test(integer) RETURNS INTEGER AS '
BEGIN
test($1, default_value_for_param2);
END;
' LANGUAGE 'plpgsql';
and also:
CREATE FUNCTION test() RETURNS INTEGER AS '
BEGIN
test(default_value_for_param1);
END;
' LANGUAGE 'plpgsql';
Hope this is what you were looking for.
--Phil.
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: spam_from_postgresql_sql@chezphil.org, Pradeepkumar.Pyatalo@honeywell.com
Subject: Re: Function Parameters - need help !!!
In-Reply-To: <2733210@chezphil.org>
* 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