Take a look at the documentation and examples again:
http://www.postgresql.org/docs/8.2/interactive/plpgsql-control-
structures.html#PLPGSQL-RECORDS-ITERATING
There are two forms to iterate over the query:
1. FOR target IN query LOOP
2. FOR target IN EXECUTE text_expression LOOP
In your code you have mixed the two together. You appear to be trying
to concatenate a string on to the end of a query expression. My
suggestion is to eliminate the string you created (_WHERECLAUSE) and
add the proper conditions to the query expression you already have.
On Jan 17, 2007, at 5:33 PM, Jan Meyland Andersen wrote:
> I have some problem with writing a function.
>
> I have made this function which I can't get it to work.
>
> This is probaly a triviel question but i'm new to plsql, so this is a
> showstopper for me.
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL