Re: plpgsql default arguments - Mailing list pgsql-general

From Pavel Stehule
Subject Re: plpgsql default arguments
Date
Msg-id Pine.LNX.4.44.0504141738030.17732-100000@kix.fsv.cvut.cz
Whole thread Raw
In response to plpgsql default arguments  (Greg Lindstrom <greg.lindstrom@novasyshealth.com>)
Responses Re: plpgsql default arguments  (Neil Conway <neilc@samurai.com>)
List 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


pgsql-general by date:

Previous
From: Greg Lindstrom
Date:
Subject: plpgsql default arguments
Next
From: Kevin MacClay
Date:
Subject: Re: pgpool with PostgreSQL 7.4