I am executing an SQL query via jcc to run a report. When I opened the error log file for the program and examined the SQL query, everything seems to be fine (There are no extra or missing brackets, commas, etc and the syntax is good) however when I execute I am getting this error:
[Report.execute()] DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=,;ATE IN (1,2,3,10,1) ;, DRIVER=4.12.55
When I researched about the SQLCODE I found out that it means there is an illegal symbol in the query. What can I look for to find this illegal symbol?
This is the query
Sorry for the tiny font but if you zoom 200% or so you can see the query better.
Thanks a lot :)
The SQLCODE field contains the SQL return code. The code can be zero (0), negative or positive: 0 means that the execution was successful. Negative values indicate an unsuccessful execution with an error. An example is -911, which means that a timeout has occurred with a rollback.
Information about an error that occurs in the scope of the TRY block of a TRY... CATCH construct can be obtained in Transact-SQL code by using functions such as ERROR_LINE, ERROR_MESSAGE, ERROR_NUMBER, ERROR_PROCEDURE, ERROR_SEVERITY, and ERROR_STATE in the scope of the associated CATCH block.
During application update an error message containing "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ..." appears in the log. It means your database is outdated and it can't work with the request our application sends to it.
You have a comma (where you shouldn't) at the end of this line:
AND Tick.STATE IN (1,2,3,10,1),
The following line also has the same problem.
Generally this SQL error code denotes that you have inserted some extra characters, such as ',' or '(' or ')' or kind of. Checking the complete query in the trace will help for the people who write Sql queries inside a Java Program or such, as it took around 2 hours for me to figure out that I have a extra ')' in my query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With