pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to create function with unspecified number of input parameters ?
5+ messages / 4 participants
[nested] [flat]

* How to create function with unspecified number of input parameters ?
@ 2001-11-25 04:25  MindTerm <mindterm@yahoo.com>
  0 siblings, 2 replies; 5+ messages in thread

From: MindTerm @ 2001-11-25 04:25 UTC (permalink / raw)
  To: pgsql-sql

Dear all,

  I am writing to ask how to create function ( CREATE
FUNCTION ) with unspecified number of input parameters
? e.g. I like to create a function similar to the
structure of COALESCE :

COALESCE( ... , [..] )

M.T.



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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to create function with unspecified number of input parameters ?
@ 2001-11-25 04:49  Tom Lane <tgl@sss.pgh.pa.us>
  parent: MindTerm <mindterm@yahoo.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Tom Lane @ 2001-11-25 04:49 UTC (permalink / raw)
  To: MindTerm <mindterm@yahoo.com>; +Cc: pgsql-sql

MindTerm <mindterm@yahoo.com> writes:
>   I am writing to ask how to create function ( CREATE
> FUNCTION ) with unspecified number of input parameters

CREATE FUNCTION doesn't presently support that.

If the underlying function is written in C, you can fake it by
issuing multiple CREATE FUNCTION commands with different numbers
of declared parameters, all of which point to the same C function.
Then the C code would have to look at fcinfo->nargs to see how it
had been called.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to create function with unspecified number of input parameters
@ 2001-11-25 05:29  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Bruce Momjian @ 2001-11-25 05:29 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: MindTerm <mindterm@yahoo.com>; pgsql-sql

> MindTerm <mindterm@yahoo.com> writes:
> >   I am writing to ask how to create function ( CREATE
> > FUNCTION ) with unspecified number of input parameters
> 
> CREATE FUNCTION doesn't presently support that.
> 
> If the underlying function is written in C, you can fake it by
> issuing multiple CREATE FUNCTION commands with different numbers
> of declared parameters, all of which point to the same C function.
> Then the C code would have to look at fcinfo->nargs to see how it
> had been called.

Is this a TODO item?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to create function with unspecified number of input parameters ?
@ 2001-11-25 05:38  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2001-11-25 05:38 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: MindTerm <mindterm@yahoo.com>; pgsql-sql

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Is this a TODO item?

Dunno.  I certainly wouldn't be in favor of unspecified arguments
(like ANSI C's "..." construct), because it'd totally destroy our
datatype resolution mechanism.  Optional arguments might work, but
it needs some careful thought.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to create function with unspecified number of input
@ 2001-11-25 19:39  Aasmund Midttun Godal <postgresql@envisity.com>
  parent: MindTerm <mindterm@yahoo.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Aasmund Midttun Godal @ 2001-11-25 19:39 UTC (permalink / raw)
  To: mindterm@yahoo.com; +Cc: pgsql-sql

Perhaps you could pass an array into it instead?

Regards,

Aasmund.

On Sat, 24 Nov 2001 20:25:21 -0800 (PST), MindTerm <mindterm@yahoo.com> wrote:
> Dear all,
> 
>   I am writing to ask how to create function ( CREATE
> FUNCTION ) with unspecified number of input parameters
> ? e.g. I like to create a function similar to the
> structure of COALESCE :
> 
> COALESCE( ... , [..] )
> 
> M.T.
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2001-11-25 19:39 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-25 04:25 How to create function with unspecified number of input parameters ? MindTerm <mindterm@yahoo.com>
2001-11-25 04:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-11-25 05:29   ` Re: How to create function with unspecified number of input parameters Bruce Momjian <pgman@candle.pha.pa.us>
2001-11-25 05:38     ` Tom Lane <tgl@sss.pgh.pa.us>
2001-11-25 19:39 ` Re: How to create function with unspecified number of input Aasmund Midttun Godal <postgresql@envisity.com>

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