Re: [GENERAL] Functions

From: Simon Drabble <simon(at)eskimo(dot)com>
To: "Aaron J(dot) Seigo" <aaron(at)gtv(dot)ca>
Cc: Postgres Group <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Functions
Date: 1999-11-03 22:08:03
Message-ID: Pine.LNX.4.10.9911031707050.21341-100000@dragon.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 3 Nov 1999, Aaron J. Seigo wrote:

> hi...
>
> > CREATE FUNCTION fn_fubar(int4) AS
> > 'UPDATE foo SET bar = tmp.numb FROM tmp WHERE tmp.numb = $$'
> > LANGUAGSE 'sql';
>
> i hate $1, $2 personally.. they make my eyes cross eventually (esp. once you
> have 3 or 4 params.. ick) and they are hard to maintain in larger functions
> (what was that $2 param again???)
>
> so i usually use pl/pgsql and do this:
>
> CREATE FUNCTION fn_fubar(int4) returns int4 AS '
> DECLARE
> myParam alias for $1;
> BEGIN
> UPDATE foo SET bar = tmp.numb FROM tmp WHERE tmp.numb = myParam;
> return myParam;
> END; '
> LANGUAGSE 'pl/pgsql';
>
> more typing, but easier to read and maintain later... but then, i'm picky.
>
> --
> Aaron J. Seigo
> Sys Admin

Ok, thanks, I must admit I wasn't really aware of pl/pgsql, so this gives me a
reason to look into it.

Simon.

>

--
"Linux - open doors, not windows."

Simon Drabble It's like karma for your brain.
simon(at)eskimo(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert 1999-11-03 22:45:14 6.5 connection time: too slow (?)
Previous Message Simon Drabble 1999-11-03 22:06:29 Re: [GENERAL] Functions