Thread: Function returning RECORD

Function returning RECORD

From
"Cristian Custodio"
Date:
Hi,

I'm not be able to use a function to return the record type.

AnyBody could help me? Look this exemple:

CREATE OR REPLACE FUNCTION TESTERECORD()
RETURNS record AS '
DECLARE
vRecRetorno Record;
BEGIN
 SELECT teste INTO vRecRetorno FROM (SELECT ''Function record '' AS teste) AS TABELA;
 RETURN vRecRetorno;
END;
' language 'plpgsql';
 
 
 
CREATE OR REPLACE FUNCTION TESTECHAMARECORD()
RETURNS varchar AS '
DECLARE
vrecord RECORD;
v varchar;
BEGIN
 SELECT testerecord() INTO vrecord;
 v := vrecord.teste; -- Here is the error
 RETURN v;
end;
' language 'plpgsql';
 

select testechamarecord();

When I call the testechamarecord function, the following message error appear:

record "vrecord" has no field named "teste"
 

Help-me, please.

Cristian Luciano Custodio