Re: plpgsql function parameter questions - Mailing list pgsql-general

From Tom Lane
Subject Re: plpgsql function parameter questions
Date
Msg-id 12842.999563560@sss.pgh.pa.us
Whole thread Raw
In response to Re: plpgsql function parameter questions  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
>> 1.  what version of pg do i need to go to in order to eliminate the '16
>> parameter maximum' restraint?

Build your own version with a suitable value of FUNC_MAX_ARGS (a/k/a
INDEX_MAX_KEYS) in src/include/config.h.

>> 2.  can i pass an array of integers to a function?  can i return an array of
>> integers?  if so, what would the function definition look like?

test71=# create function foo (integer[]) returns integer[] as '
test71'# begin
test71'# return $1;
test71'# end;' language 'plpgsql';
CREATE
test71=# select foo('{1,2,3}');
   foo
---------
 {1,2,3}
(1 row)

Actually doing any serious manipulation of an array in plpgsql might be
tricky, however.  In particular, I don't see any simple way to construct
an array value from scratch.  You might have better luck with pltcl.
There are examples of array-value manipulation in pltcl's self-test, IIRC.

            regards, tom lane

pgsql-general by date:

Previous
From: "Alex Knight"
Date:
Subject: Re: [WAY OT] Re: PL/java?
Next
From: "Karen Ellrick"
Date:
Subject: Re: Questions about unicode.