Re: Porting Oracle Decode to Postgresql

From: MindTerm <mindterm(at)yahoo(dot)com>
To: "Michael Ansley \(UK\)" <Michael(dot)Ansley(at)intec-telecom-systems(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Porting Oracle Decode to Postgresql
Date: 2001-11-22 10:21:53
Message-ID: 20011122102153.4733.qmail@web20204.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear Michael Ansley ,

It seems that c program in postgresql support
unspecified number of input parameter. The example is
as following :

But in the CREATE FUNCTION , it needs to specify the
number and type of arguments... how to rewrite it to
support vary number of input parameters ?

c program:

PG_FUNCTION_INFO_V1(c_overpaid);

Datum
c_overpaid(PG_FUNCTION_ARGS)
{
TupleTableSlot *t = (TupleTableSlot *)
PG_GETARG_POINTER(0);
int32 limit = PG_GETARG_INT32(1);
bool isnull;
int32 salary;

salary = DatumGetInt32(GetAttributeByName(t,
"salary", &isnull));
if (isnull)
PG_RETURN_BOOL(false);
/* Alternatively, we might prefer to do
PG_RETURN_NULL() for null salary */

PG_RETURN_BOOL(salary > limit);
}

--- "Michael Ansley (UK)"
<Michael(dot)Ansley(at)intec-telecom-systems(dot)com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Well, because you can overload functions, I guess
> that you could
> create a new decode for each number of parameters up
> to a limit. Is
> it likely that your program uses more than about
> eight or nine
> parameters? Then create the three or four overloads
> that it needs to
> get that many, and if you need more, then just
> create them when you
> do.
>
> Cheers...
>
>
> MikeA

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

Browse pgsql-sql by date

  From Date Subject
Next Message Gurudutt 2001-11-22 10:40:18 Re: Joins~
Previous Message MindTerm 2001-11-22 09:54:57 Re: Porting Oracle Decode to Postgresql