Reputation: 680
The Java based Application is using common select query to extract records from all databases. The records with null values for a particular column(here 'id') should get dropped.
This is the query:
SELECT * from Employee WHERE 1=1 AND id IS NOT NULL AND cast(id as varchar) !=''
It works fine for all databases but gives SQLException for DB2.
The goal is :
Upvotes: 0
Views: 1925
Reputation: 1269873
Although this won't affect your problem, I would use the <>
operator instead of !=
(the former is definitely part of the standard; I'm not sure if newer versions of the standard insist on !=
being supported):
SELECT *
from Employee
WHERE 1=1 AND id IS NOT NULL AND id <> '';
The next suspicious thing is comparing an id
to a string. If id
is a string, then no problem. However, if it is numeric, you might have a type incompatibility. Try one of these where
clauses:
WHERE 1=1 AND id IS NOT NULL AND id <> 0;
or
WHERE 1=1 AND id IS NOT NULL AND cast(id as varchar(255)) <> '';
Upvotes: 0