Subject Re: [Firebird-Java] problem: PreparedStatement with "? IS NULL"
First of all, remove those horrible quotes around table and column names,
it is not an SQL standard. If MS SQL let you do this way, MS SQL should be
dropped outside the window :-P
The rest of the code is strange, it's meaningless to me. Why do you have
to put "Types.INTEGER" as a parameter? And what do you want at the third
parameter, a column?
Antonio Petrelli

bullitenergy wrote:

> Hello everyone!
> Sorry if this question has already been asked... I could not find any
> answers in Google. I also posted this question to the Dev Shed
> Firebird SQL forum. The example code breaks on the prepareStatement,
> probably because Jaybird or Firebird is unable to determine the type
> of the third parameter:
> 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