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

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: "The tuple structure of a not-yet-assigned record is indeterminate."
Date: 2008-06-30 14:47:22
Message-ID: dbbf25900806300747u6ee2f006p35973e1c6e0d564f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I can try your suggestion, but I'd rather want to know why it doesn't
work with the record, when you try to build it your self. It worked
fine when you selected into the record.
But speaking of that, If I try like you did:

SELECT INTO retval <some expression build from the variables tmp.id,
_c3, _c2 that constitutes a row>
RETURN NEXT retval;
wouldn't that work?
I think I need some help with the syntax for the expression above...

I will also try to create a datatype of my own and see if that works
as a last way out.

2008/6/30 A. Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com>:
> am Mon, dem 30.06.2008, um 14:25:30 +0200 mailte A B folgendes:
>> I did read the select line also, and
>> select * from foo() as (a integer, b integer, c integer);
>> gives me unfortunatly the error
>> ERROR: record "retval" is not assigned yet
>> DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
>
> Okay, right, i see. You can rewrite your function using IN/OUT-parameters.
>
>
> For instance, your function:
>
> 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;
>
>
> rewrite to:
>
>
> CREATE OR REPLACE FUNCTION foo(OUT jd int, OUT d2 int, OUT d3 int) RETURNS SETOF RECORD AS $$
> BEGIN
> some loop
> jd := tmp.id;
> d2 := _c2;
> d3 := _c3;
> RETURN NEXT;
> end loop;
> return;
> END;
>
>
>
> *untested*.
>
>
> Hope that helps, Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
> NGnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-06-30 14:51:36 Re: "out of balance" result on select from suspected index corruption
Previous Message Chandra ASGI Tech 2008-06-30 14:24:47 Re: php + postgresql website ?