What can SQL CODE -104 (error) represent?
Asked Answered
H

4

14

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

Hutton answered 22/2, 2013 at 10:39 Comment(2)
Wouldn't it make sense for you to post the query? Someone might be able to spot the symbol for you.Witless
it is a bit long that's why I didn't post it! Well let me include it thenHutton
L
18

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.

Lyrebird answered 22/2, 2013 at 10:55 Comment(2)
oh! sorry I'm still new to this! I thought that wasn't bad! Thanks for your help!Hutton
I had extra unnecessary ; at the end.Kerenkeresan
C
6

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.

Checkrow answered 24/8, 2015 at 12:3 Comment(2)
In my case it was a ; at the end of queryNitriding
In mine it was "\n" (I'm using jdbcTemplate)Petree
R
0

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)

Rumpus answered 24/12, 2015 at 9:58 Comment(0)
L
0

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

Lixiviate answered 19/8, 2016 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.