Re: Function problem after alter table - Mailing list pgsql-novice

From Tom Lane
Subject Re: Function problem after alter table
Date
Msg-id 652.1204580433@sss.pgh.pa.us
Whole thread Raw
In response to Function problem after alter table  (Sean Dooley <srd1@st-andrews.ac.uk>)
Responses SQL Question  (Joshua <joshua@joshuaneil.com>)
List pgsql-novice
Sean Dooley <srd1@st-andrews.ac.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

pgsql-novice by date:

Previous
From: Sean Dooley
Date:
Subject: Function problem after alter table
Next
From: Joshua
Date:
Subject: SQL Question