2017-07-27 16:03 GMT+02:00 Tom Lane <tgl@xxxxxxxxxxxxx>: Thanks a lot for your reply with valuable details. > Vincenzo Romano <vincenzo.romano@xxxxxxxxxxx> writes: >> CREATE OR REPLACE FUNCTION afun1( OUT ot TEXT ) >> RETURNS SETOF RECORD > >> The error message for afun1() reads: >> ERROR: function result type must be text because of OUT parameters > > Indeed. It's trying to protect you from simple typos. Which typo? It looks it's preventing me from consistently using another simple syntax for FRSes. CREATE OR REPLACE FUNCTION afun1( OUT ot TEXT ) RETURNS SETOF TEXT ... CREATE OR REPLACE FUNCTION afun2( OUT ot TEXT, OUT it INT ) RETURNS SETOF RECORD ... CREATE OR REPLACE FUNCTION afun3( OUT ot TEXT, OUT it INT, OUT on NUMERIC ) RETURNS SETOF RECORD ... CREATE OR REPLACE FUNCTION afun4( OUT ot TEXT, OUT it INT, OUT on NUMERIC, OUT od DATE ) RETURNS SETOF RECORD ... This means that RETURNS SETOF RECORD syntax is only available from 2 columns on. While RETURNS TABLE() syntax is always available, *also* for 1 column. I thought that "RETURNS SETOF RECORD" was meant for FRSes just like RETURN TABLE() is. Why not, then? > If you want a consistent syntax I'd suggest > > CREATE OR REPLACE FUNCTION afun1() RETURNS TABLE (ot text) ... Indeed. The main difference is that with RETURNS SETOF RECORD I still get the "usual"(tm) function argument list in the usual place: between two parentheses. It's a matter of style. And a consistent one. But I still don't get the point for not having it for a single column. Surely it's my fault. > It's still really "setof text" under the hood. > > regards, tom lane -- Vincenzo Romano - NotOrAnd.IT Information Technologies -- NON QVIETIS MARIBVS NAVTA PERITVS -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general