Tuesday, October 4, 2016

How to get to the correct position of a syntax error in postgresql

Sometimes position of a syntax returned by PostgreSQL is not correct. You try to go to the specified position in a query (in any text editor) and it shows something totally unrelated. Probably this is due to comments or new lines or something else. And with large queries it can be frustrating to look through it all for some really simple mistake.

In order to get the correct position you will need to execute the query in PostgreSQL's own pgAdmin III tool. The position number will still be incorrectly reported but the cursor will be automatically moved to the position of an error cause. Handy!