Re: Function Parameters - need help !!! - Mailing list pgsql-sql

From Phil Endecott
Subject Re: Function Parameters - need help !!!
Date
Msg-id 2733210@chezphil.org
Whole thread Raw
In response to Re: Function Parameters - need help !!!  ("Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar.Pyatalo@honeywell.com>)
List pgsql-sql
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.


pgsql-sql by date:

Previous
From: "Pradeepkumar, Pyatalo (IE10)"
Date:
Subject: Re: Function Parameters - need help !!!
Next
From: Richard Huxton
Date:
Subject: Re: Function Parameters - need help !!!