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.Ansley@intec-telecom-systems.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