variable-count stored proc arguements?

Started by Benabout 23 years ago3 messagesgeneral
Jump to latest
#1Ben
bench@silentmedia.com

Is there such a thing? My guess is there isn't, but I'm trying to figure
out how to encapsulate some "select where foo=a [and foo=b [and foo=c
[...]]]" logic into a stored proc, and that would be an elegant way to
do it.

AFAICT, the next-best alternative is to take a specially-formated text
string as an argument, and then break that up and reassemble it into the
query I want. Not knowing PL/pgSQL very well, I think that implies
writing the function in C, which simply seems overkill for this.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ben (#1)
Re: variable-count stored proc arguements?

Ben <bench@silentmedia.com> writes:

Is there such a thing?

No. If you are working in C, it's possible to make multiple pg_proc
entries pointing to the same C function, but this is a tedious way to
do things; and it doesn't scale to large numbers of arguments.

My guess is there isn't, but I'm trying to figure
out how to encapsulate some "select where foo=a [and foo=b [and foo=c
[...]]]" logic into a stored proc, and that would be an elegant way to
do it.

Perhaps pass the a,b,c values as an array?

regards, tom lane

#3Ben
bench@silentmedia.com
In reply to: Tom Lane (#2)
Re: variable-count stored proc arguements?

Ah, yes, I always forget about arrays. That worked perfectly. Thanks!

On Sat, 2003-03-29 at 15:32, Tom Lane wrote:

Show quoted text

Perhaps pass the a,b,c values as an array?

regards, tom lane