Thread: more than 32 parameters to a function?
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.
Attachment
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)
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;
--
William Leite Araújo
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
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.
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.
Attachment
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.
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!
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
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.
Attachment
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