In question How to generate an array of given size, with one field populated? I have been instructed to write instead of a “returns” an “OUT” statement for a function definition.
The reason was that in that case I may assign to the OUT variable an anyarray “type” that seems impossible to do with return.
As I see that OUT is more flexible than “returns” I am wandering if I may use it for all my functions or if there is any drawback or difference that I do not understand.
By the way, I have to note that when there is only one OUT it seems to me that the result is exactly equal to return, while instead if there are more OUT then the output is a ‘record’ of the OUTs.
In order to understand without reading the above question, I repeat bellow the code in question:
My tentative wrong initial code was:
create function arraycol(v anyelement,n int,i int) returns anyarray language plpgsql
and it has been exchanged with
create function arraycol(v anyelement,n int,i int,OUT r anyarray) language plpgsql
TO RESUME may I change all returns to OUT ? and forget about return forever ?