سؤال

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 :)

هل كانت مفيدة؟

المحلول

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.

In My Case Problem was little different I wanted to joing two tables and then copy data from Table2 to Table1 respective column My Query (DB2) update Table1 T1, Table2 T2 set T1.DEST_COLMN= T2.SRC_COLMN where T1.ID= T2.ID

Correct Query update Table1 T1 set T1.DEST_COLMN = (select SRC_COLMN from Table2 T2 where T1.ID= T2.ID)

I crashed this error because one of my query builder parameters was null and query was something like ".. OrderType = 'CM' and null".

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top