Skip to content
Advertisement

Any way to get a more meaningful error message in postgres?

Let’s have some tea …

Let’s test this …

syntax error at or near “countries_with_tea”

I don’t see it. It’s probably quite obvious, but I just don’t see it.

Does anybody spot what’s wrong with this? Or if not, is there any way I can get a more meaningful error from postgres than “there was a syntax error (but I don’t tell you what it was)”?

Advertisement

Answer

Your loop over the is wrong, you need to use FOREACH to loop through the elements of an array:

You don’t really need a UNION, you can use return query to return multiple results:

Online example


If you need that a log, it might be better to use table inheritance or a view to create a single table that contains all others.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement