Re: Semi-Pseudo Data Types & Procedure Arguments

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Semi-Pseudo Data Types & Procedure Arguments
Date: 2013-06-26 15:53:25
Message-ID: 1372262005343-5761175.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Johnston wrote
>
> Tom Lane-2 wrote
>>
>>> -- A stored procedure which can accept two argument, which can be a
>>> single
>>> integer field, or an array of integers.
>>
>> Those two cases seem unlikely to be supportable by the same
>> implementation, so it seems more likely that what you'd be doing is just
>> overloading the function name with two instances, my_fn(int) and
>> my_fn(int[]).
> Isn't this scenario why VARIDIC was implemented:
>
> CREATE FUNCTION my_fn( VARIADIC in_ordered_actual varchar[] ) ....
>
> The single value input is simply a special case of an array of size 1.
> Depending on whether you allow an empty array you might want to:
>
> CREATE FUNCTION my_fn(required_first varchar, VARIADIC optional_others
> varchar[] DEFAULT '{}'::varchar[]) ...
>
> Then join the two values together and move on to processing.
>
> You would still need separate functions for numbers versus strings.
>
> David J.

So my thoughts stand for generating ideas but you cannot actually supply an
array as an input to a VARIDIC routine; it simply allows for an unknown
number of inputs (of the same type) and constructs an array internally for
the function to use.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Semi-Pseudo-Data-Types-Procedure-Arguments-tp5761158p5761175.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jake Silverman 2013-06-26 15:59:01 Re: Need help compiling from souce
Previous Message David Johnston 2013-06-26 15:47:43 Re: Semi-Pseudo Data Types & Procedure Arguments