
September 21st, 2004, 08:03 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
PreparedStatement with "? IS NULL"
Hello everyone!
Sorry if this question has already been asked... I could not find any answers in Google. This code breaks on the prepareStatement, probably because Jaybird or Firebird is unable to determine the type of the third parameter:
Code:
String DELETE_A =
"DELETE FROM \"A\" WHERE \"id\" = ? AND"
+ "(\"a\" = ? OR (\"a\" IS NULL AND ? IS NULL))";
PreparedStatement ps;
ps = connection.prepareStatement(DELETE_A);
int index=1;
ps.setInt(index++, value.getId());
if(value.getA() == null) {
ps.setNull(index++, Types.INTEGER);
ps.setNull(index++, Types.INTEGER);
} else {
ps.setInt(index++, value.getA().intValue());
ps.setInt(index++, value.getA().intValue());
}
ps.executeUpdate();
Is this expected behavior? (This style of querying works in MS-SQL)
Is there some way to achieve the same effect?
I don't want to use 2 different SQL statements, because I have lots of more columns that can have NULL values.
Thank you for your answers!
Best regards!
Bullit Energy
|