Re: plpgsql default arguments

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: Greg Lindstrom <greg(dot)lindstrom(at)novasyshealth(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql default arguments
Date: 2005-04-14 15:45:58
Message-ID: Pine.LNX.4.44.0504141738030.17732-100000@kix.fsv.cvut.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I am running postgres on a Linux system and have been using plpgsql to
> write functions. Is there a way to specify default arguments?

Hello,

there is no possibility define default arguments. But you can write
functions with different count of arguments.

CREATE OR REPLACE FUNCTION foo(integer, integer) RETURNS integer AS $$
BEGIN
RETURN $1 + $2;
END; $$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION foo(integer) RETURNS integer AS $$
BEGIN
RETURN foo($1,10); -- 10 is "default" value
END; $$ LANGUAGE plpgsql;

Regards
Pavel Stehule

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin MacClay 2005-04-14 15:46:22 Re: pgpool with PostgreSQL 7.4
Previous Message Greg Lindstrom 2005-04-14 15:26:38 plpgsql default arguments