Skip site navigation (1) Skip section navigation (2)

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

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(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 12:39:17
Message-ID: 20080630123917.GI13270@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-general
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

In response to

Responses

pgsql-general by date

Next:From: Sam MasonDate: 2008-06-30 12:51:31
Subject: Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks
Previous:From: Dimitri FontaineDate: 2008-06-30 12:38:10
Subject: Re: php + postgresql website ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group