pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: MindTerm <mindterm@yahoo.com>
To: Michael Ansley \(UK\) <Michael.Ansley@intec-telecom-systems.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Porting Oracle Decode to Postgresql
Date: Thu, 22 Nov 2001 02:21:53 -0800 (PST)
Message-ID: <20011122102153.4733.qmail@web20204.mail.yahoo.com> (raw)
In-Reply-To: <7F124BC48D56D411812500D0B747251401DA3E3D@fileserver002.intecsystems.co.uk>

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



view thread (4+ messages)

Message-ID: <20011122102153.4733.qmail@web20204.mail.yahoo.com>
Permalink:  ../20011122102153.4733.qmail@web20204.mail.yahoo.com/
Also on:    postgresql.org/message-id/20011122102153.4733.qmail@web20204.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mindterm@yahoo.com, Michael.Ansley@intec-telecom-systems.com
  Subject: Re: Porting Oracle Decode to Postgresql
  In-Reply-To: <20011122102153.4733.qmail@web20204.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox