Re: "The tuple structure of a not-yet-assigned record is indeterminate."

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: "The tuple structure of a not-yet-assigned record is indeterminate."
Дата
Msg-id 20080630114639.GG13270@a-kretschmer.de
обсуждение исходный текст
Ответ на "The tuple structure of a not-yet-assigned record is indeterminate."  ("A B" <gentosaker@gmail.com>)
Ответы Re: "The tuple structure of a not-yet-assigned record is indeterminate."  ("A B" <gentosaker@gmail.com>)
Список pgsql-general
am  Mon, dem 30.06.2008, um 13:33:55 +0200 mailte A B folgendes:
> In my function I have (kept the important part)
>
> CREATE OR REPLACE FUNCTION foo() RETURNS SETOF RECORD AS $$
> DECLARE
>     retval RECORD;
> BEGIN
>      some loop
>            retval.jd := tmp.id;
>            retval.d2 := _c2;
>            retval.d3 := _c3;
>            RETURN NEXT retval;
>     end loop
> return;
> END;
>
> and I get
>
> ERROR:  record "retval" is not assigned yet
> DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
> CONTEXT:  PL/pgSQL function "foo" line 33 at assignment
>
> It seems that the line with   retval.jd := tmp.id;  is where it stops.
> Any suggestion on how to fix this error?

Sure, declare your result like my example:

test=# create or replace function ab() returns setof record as $$declare r record; begin select into r 1,2;return next
r;end;$$languageplpgsql; 
CREATE FUNCTION
test=*# select * from ab() as (i int, j int);
 i | j
---+---
 1 | 2
(1 row)



Regards, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

В списке pgsql-general по дате отправления:

Предыдущее
От: "A B"
Дата:
Сообщение: "The tuple structure of a not-yet-assigned record is indeterminate."
Следующее
От: "A B"
Дата:
Сообщение: Re: "The tuple structure of a not-yet-assigned record is indeterminate."