Thread: Array as a parameter in user-defined functions

Array as a parameter in user-defined functions

From
mila boldareva
Date:
Hello!

I have a row in the table which is an array of floats, like, (foo float[8])

I'd like to use a function to perform some operations on that array,
access single elements of that row, like foo[1]+foo[2]. Is it possible
to pass an array to an SQL function as a parameter?

CREATE FUNCTION ADD (float[8], float[8]) RETURNS float AS ' ....

doesn't work. I might try C as well, but, again, how do I pass this float array?

Thanks,
mila
mailto:pierro@dds.nl


Re: Array as a parameter in user-defined functions

From
Tom Lane
Date:
mila boldareva <pierro@dds.nl> writes:
> CREATE FUNCTION ADD (float[8], float[8]) RETURNS float AS ' ....

> doesn't work.

Works fine for me, at least in recent releases.  If you're using
something older than say 7.1, you might need to update.

            regards, tom lane