Re: Function problem after alter table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sean Dooley <srd1(at)st-andrews(dot)ac(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Function problem after alter table
Date: 2008-03-03 21:40:33
Message-ID: 652.1204580433@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Sean Dooley <srd1(at)st-andrews(dot)ac(dot)uk> writes:
> FOR RESULTSET IN
> SELECT * FROM item_date WHERE item_id = in_item_id
> LOOP
> RETURN NEXT resultset;
> END LOOP;

> This works fine, returns all the matching data from item_date
> However, if I alter the table item_date, for example
> ALTER TABLE item_date ADD COLUMN foo text;
> When I run the function now, I get the error
> ERROR: wrong record type supplied in RETURN NEXT

This example works for me in PG 8.3. In prior releases I think you'd
need to use FOR ... IN EXECUTE to force the SELECT to get re-planned
each time through.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Joshua 2008-03-03 22:21:06 SQL Question
Previous Message A. Kretschmer 2008-03-03 14:16:26 Re: Triggers | rules for column updates