From: | Andrew Perrin <aperrin(at)socrates(dot)berkeley(dot)edu> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | create function w/indeterminate number of args? |
Date: | 2001-02-26 05:04:45 |
Message-ID: | Pine.LNX.4.21.0102260001380.8089-100000@nujoma.perrins |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Greetings.
I find myself in need of a minimum() function. This is different from the
min() function, which operates across records; what I need is to be able
to say:
UPDATE foo SET newcol = minimum(field1, field2, field3, field4);
From what I can tell there is no such beast built in, but I would be happy
to be proved wrong.
Anyway... I can write such a function easily enough in perl, probably
something like:
my $min=$_[0];
$min > $_ and $min = $_ foreach @_;
return $min;
but I can't determine how to allow varying numbers of arguments to be
passed to a function. That is, sometimes I need minimum(arg1, arg2) but
sometimes it's minimum(arg1, arg2, arg3, arg4, arg5), etc.
Thanks-
Andy Perrin
----------------------------------------------------------------------
Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology
Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin
aperrin(at)socrates(dot)berkeley(dot)edu - aperrin(at)igc(dot)apc(dot)org
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Sawtell | 2001-02-26 06:51:17 | Re: conversion |
Previous Message | Ken Kline | 2001-02-26 04:11:22 | Re: conversion |