On 01/12/2012 19:44, Peter Kroon wrote: > Mmmmm....... > > How do I execute dynamic sql that starts with an if statement. > I'm converting mssql code to pgsql. > Without trying it, I'd guess that you need to have the IF outside the dynamic code, something like this: if .... then execute '.....'; end if; If you show what you're trying to achieve, someone might be able to suggest something better. Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@xxxxxx -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general