> >> How should this be written ? > > I don't think you can use the "IF" like this in a normal query. You could > write a pl/pgsql function instead to do this.. You can write such a query inline in 9.0, by use of DO...but you probably just want to define a function for now -- Regards, Peter Geoghegan -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general