Hi all.
Please, see this fragment:
DROP TABLE IF EXISTS atable;
CREATE TABLE atable (
atext TEXT,
anint INT
);
TRUNCATE atable;
INSERT INTO atable VALUES
( 'one',1 ),
( 'two',2 ),
( 'three',3 ),
( 'four',4 )
;
CREATE OR REPLACE FUNCTION afun1( OUT ot TEXT )
RETURNS SETOF RECORD
LANGUAGE PLPGSQL
AS $l0$
BEGIN
RETURN QUERY SELECT atext FROM atable;
END;
$l0$;
CREATE OR REPLACE FUNCTION afun2( OUT ot TEXT, OUT oi INT )
RETURNS SETOF RECORD
LANGUAGE PLPGSQL
AS $l0$
BEGIN
RETURN QUERY SELECT atext,anint FROM atable;
END;
$l0$;
I am not allowed to create afun1() but can create and use afun2().
The error message for afun1() reads:
ERROR: function result type must be text because of OUT parameters
The idea I understand is that a RECORD must have no less than TWO columns.
Of course it's not a problem to declare "RETURNS SETOF TEXT", but why
forcing me to "deviate" from a very general construct for a 1 column
case?
Is this a bug/enhancement or am I missing something?
TALIA!
--
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS