bastel
bastel

Reputation: 51

Why do I get an SyntaxErrorException while executing query on DB2?

I tried to get the countries beginning with L, however I get an error when I try to use the WHERE COUNTRY INTO 'L%' statement.

String sql = "SELECT COUNTRY, LER "  
 + "FROM CENSUS.WORLDIMR "    
 + "WHERE COUNTRY INTO 'L%'"; 

I recieve the following exception:

com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-199, SQLSTAT
E=42601, SQLERRMC=INTO;??( [ CONCAT || / MICROSECONDS MICROSECOND SECONDS SECOND
, DRIVER=4.18.74       

It's definitely something wrong with WHERE COUNTRY INTO 'L%'. I had the same problem with COBOL. Adding 29 times % fixed it but this time it's different.

Upvotes: 0

Views: 1027

Answers (1)

Keammoort
Keammoort

Reputation: 3075

I believe you need to use LIKE operator:

SELECT COUNTRY, LER FROM CENSUS.WORLDIMR WHERE COUNTRY LIKE 'L%';

Upvotes: 3

Related Questions