Received: from web20204.mail.yahoo.com (web20204.mail.yahoo.com [216.136.226.59]) by postgresql.org (8.11.3/8.11.4) with SMTP id fAMALqm28919 for ; Thu, 22 Nov 2001 05:21:52 -0500 (EST) (envelope-from mindterm@yahoo.com) Message-ID: <20011122102153.4733.qmail@web20204.mail.yahoo.com> Received: from [203.85.100.3] by web20204.mail.yahoo.com via HTTP; Thu, 22 Nov 2001 02:21:53 PST Date: Thu, 22 Nov 2001 02:21:53 -0800 (PST) From: MindTerm Subject: Re: Porting Oracle Decode to Postgresql To: "Michael Ansley \(UK\)" Cc: pgsql-sql@postgresql.org In-Reply-To: <7F124BC48D56D411812500D0B747251401DA3E3D@fileserver002.intecsystems.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200111/312 X-Sequence-Number: 5694 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)" 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