function returning record - Mailing list pgsql-novice

From Roberto Rezende de Assis
Subject function returning record
Date
Msg-id 427A12C8.1020806@yahoo.com.br
Whole thread Raw
Responses Re: function returning record
Re: function returning record
List pgsql-novice
pglista=# CREATE OR REPLACE FUNCTION teste(int,float)
pglista-# RETURNS record AS '
pglista'# DECLARE
pglista'#     numero ALIAS FOR $1;
pglista'#     margem ALIAS FOR $2;
pglista'#     retorno record;
pglista'# BEGIN
pglista'#     retorno.ponto := numero;
pglista'#     retorno.percentual := numero*margem;
pglista'#     RETURN retorno;
pglista'# END;
pglista'# ' LANGUAGE plpgsql;
CREATE FUNCTION

pglista=# SELECT teste(100,0.1);
ERROR:  record "retorno" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT:  PL/pgSQL function "teste" line 6 at assignment

pglista=# SELECT ponto,percentual FROM teste(100,0.1);
ERROR:  a column definition list is required for functions returning
"record"

Someone knows if it possible to return a record without creating a type
for it, or how to make that definition list that the error message show me.



pgsql-novice by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: connect from perl: error in Carp.pm
Next
From: "Peter Schonefeld"
Date:
Subject: ERROR: relation "mytable" does not exist