Christoph Haller <ch(at)rodos(dot)fzk(dot)de> writes:
>> OPEN ref FOR
>> (SELECT * FROM history WHERE obs_type =3D \'AA\' )
>> UNION
>> (SELECT * FROM history WHERE obs_type =3D \'TA\');
> My suspicion is the plpgsql parser doesn't accept the opening
> parenthesis.
Yeah. Looking at the plpgsql grammar, it expects the token after FOR to
be either SELECT or EXECUTE. This example demonstrates that that code
is wrong, so I'll fix it for 7.4. But in the meantime, why don't you
just leave out the parentheses?
regards, tom lane