more than 32 parameters to a function?

Started by Ottavio Campanaover 19 years ago10 messagesgeneral
Jump to latest
#1Ottavio Campana
ottavio@campana.vi.it

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.

I need to write a complex function with 65 arguments, but when I try to
run it I get an error complaining that arguments can be up to 32.

Is there a way to solve this problem or do I have to try to split the
function into three new ones?

--
Non c'e' piu' forza nella normalita', c'e' solo monotonia.

#2Erik Jones
erik@myemma.com
In reply to: Ottavio Campana (#1)
Re: more than 32 parameters to a function?

Put them in arrays and pass them as the arguments. But, I would like to
know what function could ever need 65 arguments?

Ottavio Campana wrote:

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.

I need to write a complex function with 65 arguments, but when I try to
run it I get an error complaining that arguments can be up to 32.

Is there a way to solve this problem or do I have to try to split the
function into three new ones?

--
erik jones <erik@myemma.com>
software development
emma(r)

#3William Leite Araújo
william.bh@gmail.com
In reply to: Ottavio Campana (#1)
Re: more than 32 parameters to a function?

Create a type whith the fields?!
Ex.:
Create type myType as (field1 integer, field2 integer, ...);
Create or replace function func_type(myType) returns integer AS
$$
DECLARE
param ALIAS FOR $1;
BEGIN
RAISE LOG 'Param fields: %, %, %, ... ', param.field1,
param.field2, ...;
END;
$$ LANGUAGE plpgsql;

2006/10/26, Ottavio Campana <ottavio@campana.vi.it>:

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.

I need to write a complex function with 65 arguments, but when I try to
run it I get an error complaining that arguments can be up to 32.

Is there a way to solve this problem or do I have to try to split the
function into three new ones?

--
Non c'e' piu' forza nella normalita', c'e' solo monotonia.

--
William Leite Araújo

#4Volkan YAZICI
yazicivo@ttnet.net.tr
In reply to: Ottavio Campana (#1)
Re: more than 32 parameters to a function?

On Oct 26 10:03, Ottavio Campana wrote:

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.

I need to write a complex function with 65 arguments, but when I try to
run it I get an error complaining that arguments can be up to 32.

Is there a way to solve this problem or do I have to try to split the
function into three new ones?

Why don't you use a record (or array) type instead?

Regards.

#5Ottavio Campana
ottavio@campana.vi.it
In reply to: Erik Jones (#2)
Re: more than 32 parameters to a function?

Erik Jones wrote:

Put them in arrays and pass them as the arguments. But, I would like to
know what function could ever need 65 arguments?

Consider that I have to invoke the function from a ZSQL method in zope.
Do you know if it works?

I need all these arguments because we have a tables where we store items
for an e-commerce site. The problem is that these items might have a
lot of peculiarities and more than 40 fields are boolean to fully
describe them.

Bye

Ottavio Campana wrote:

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.

I need to write a complex function with 65 arguments, but when I try to
run it I get an error complaining that arguments can be up to 32.

Is there a way to solve this problem or do I have to try to split the
function into three new ones?

--
Non c'e' piu' forza nella normalita', c'e' solo monotonia.

#6Volkan YAZICI
yazicivo@ttnet.net.tr
In reply to: Ottavio Campana (#5)
Re: more than 32 parameters to a function?

On Oct 26 10:55, Ottavio Campana wrote:

Erik Jones wrote:

Put them in arrays and pass them as the arguments. But, I would like to
know what function could ever need 65 arguments?

Consider that I have to invoke the function from a ZSQL method in zope.
Do you know if it works?

I need all these arguments because we have a tables where we store items
for an e-commerce site. The problem is that these items might have a
lot of peculiarities and more than 40 fields are boolean to fully
describe them.

I don't have a clue about the ZSQL issue, but it can be a solution to OR
those booleans, with some bitwise logic.

Regards.

#7David Fetter
david@fetter.org
In reply to: Ottavio Campana (#1)
Re: more than 32 parameters to a function?

On Thu, Oct 26, 2006 at 10:03:27AM -0700, Ottavio Campana wrote:

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.

I need to write a complex function with 65 arguments, but when I try
to run it I get an error complaining that arguments can be up to 32.

Is there a way to solve this problem or do I have to try to split
the function into three new ones?

You can pass the function one complex type that has as many parts as
you like. Or several complex types if that makes more sense.

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ottavio Campana (#1)
Re: more than 32 parameters to a function?

Ottavio Campana <ottavio@campana.vi.it> writes:

I'm writing some stored procedures in pl/pgsql for a database using
postgresql 7.4.7.
I need to write a complex function with 65 arguments, but when I try to
run it I get an error complaining that arguments can be up to 32.

Update to 8.1, which allows 100 by default. Or modify FUNC_MAX_ARGS and
recompile --- but be aware that in 7.4.x that change requires an initdb.

Or, as suggested elsewhere, rethink that function's API. A list of 65
arguments seems terribly error-prone to me...

regards, tom lane

#9Tino Wildenhain
tino@wildenhain.de
In reply to: Ottavio Campana (#5)
Re: more than 32 parameters to a function?

Ottavio Campana schrieb:

Erik Jones wrote:

Put them in arrays and pass them as the arguments. But, I would like to
know what function could ever need 65 arguments?

Consider that I have to invoke the function from a ZSQL method in zope.
Do you know if it works?

I need all these arguments because we have a tables where we store items
for an e-commerce site. The problem is that these items might have a
lot of peculiarities and more than 40 fields are boolean to fully
describe them.

you mean item description? Why would you update them all?
Or what are you doing w/ it?
If its kinda search for products, you wont need more then
about 6 different attributes to choose from the same time.
thats attribute name + desired value = 12 params at best.

Otherwise could you give an example usage of that more then
32 values call?

Regards
Tino

#10Ottavio Campana
ottavio@campana.vi.it
In reply to: Ottavio Campana (#1)
Re: more than 32 parameters to a function?

I just implemented the same function using an array holding all the
booleans fields describing the objects.

It works well.

Thank you to all of you.

--
Non c'e' piu' forza nella normalita', c'e' solo monotonia.