From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | rox <rox(at)tara-lu(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: What type is required to capture the RETURNING from an Update? |
Date: | 2011-09-14 20:49:43 |
Message-ID: | 5805.1316033383@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
rox <rox(at)tara-lu(dot)com> writes:
> Within 8.4, If I have an update like the following :
> EXECUTE $c$
> UPDATE field_seasons dr
> SET season_id = ds.season_id, field_id = ds.field_id
> FROM data_set ds
> WHERE ds.data_set_id = dr.data_set_id
> AND ds.season_id = _season_id
> RETURNING field_seasons_id
> $c$
> INTO _id_array;
> in a pgsql FUNCTION... What is the type on the variable that can accept
> the list of id's?
There is none, because it isn't a list it's a row set.
Personally I'd try something like
FOR id IN UPDATE ... RETURNING field_seasons_id
LOOP
... do something with id ...
END LOOP
(see "Looping Through Query Results" in the plpgsql manual).
AFAICS there's no need to use EXECUTE here.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | poultee | 2011-09-15 07:48:14 | Re: Unable to start postgres service (8.4) |
Previous Message | rox | 2011-09-14 18:50:13 | What type is required to capture the RETURNING from an Update? |