Mauri Sahlberg <Mauri(dot)Sahlberg(at)claymountain(dot)com> writes:
> If the following is executed in context, where the dynamic query returns
> data with every iteration everythin goes fine. If the the dynamic query
> returns nothing - bush becomes null and everything fails. I do not
> undestand why bush becomes null when the query returns nothing.
If "latest" is null then the result of the series of concatenations is
also null. Perhaps what you really want is to assign to "latest" inside
the inner FOR-loop.
regards, tom lane