2

How do I go about debugging a SQL statement in SQuirrel-sql?

I keep getting "unhelpful" errors like:

Error: [SQL0104] Token , was not valid. Valid tokens: ) OR.
SQLState:  42601
ErrorCode: -104

I would love to be able to see the line number where I made the error, or some other way of guiding me to where the problem is.

I am working with the JDBC driver on a IBMi DB2 database.

Christoff Erasmus
  • 925
  • 1
  • 10
  • 26

2 Answers2

3

You can add the "errors=full" property for more detailed error messages although it will still require some interpretation to locate the precise syntax issue.

See the IBM Toolbox for Java JDBC properties for more information.

As Tracy mentioned if you want interactive syntax checking you will have to use one of the native SQL interfaces such as the green screen Start SQL Interactive Session (STRSQL) command or the IBM i Access Run SQL scripts tool.

James Allman
  • 40,573
  • 11
  • 57
  • 70
2

For such errors where the problem isn't obvious, I like to copy and paste the SQL into the AS/400's green screen interactive SQL tool. (I'm assuming your database server is an AS/400 based on your tag and the mention of IBMi DB2.) The command is STRSQL. When there's an error, it will put your cursor right where the problem is. Or, more specifically, where it thinks the problem is. It does require green screen access to the AS/400.

Tracy Probst
  • 1,839
  • 12
  • 13
  • Thanks, I have used STRSQL. The "copy and paste the SQL into the AS/400's green screen" is not as easy as you make it out. For longer statements you need to copy multiple "chunks" of code. And editing with out an "Undo" button is not for me. (Another option would be RUNSQLSTM and looking at the DSPJOBLOG and then maybe SPLF) – Christoff Erasmus Nov 29 '11 at 16:03