Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can SQL CODE -104 (error) represent?

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

enter image description here

Sorry for the tiny font but if you zoom 200% or so you can see the query better.

Thanks a lot :)

like image 589
Bernice Avatar asked Feb 22 '13 10:02

Bernice


People also ask

What does SQL error code means?

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.

How do you interpret SQL errors?

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.

What is the error in my SQL syntax?

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.


2 Answers

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.

like image 115
Bohemian Avatar answered Oct 12 '22 05:10

Bohemian


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.

like image 37
ram Avatar answered Oct 12 '22 04:10

ram