Prepared statement delete problem

Hi everybody,

I’m trying to delete via prepared statments but I have a problem:

when I execute this statement (without prepared statement):
system.db.runUpdateQuery("delete from TABLE where COLUMNX = 15.4 ")
it returns me 1 indicating that I have deleted a line. It’s ok.

In the same preconditions, when I try with the prepared statement like that:
system.db.runPrepUpdate("delete from TABLE where COLUMNX = ? ", [15.4])
the statement returns 0 to me and it hasn’t deleted anything.

what am I doing wrong?

Nothing wrong with your query structure, but you have unreasonable expectations for floating point “equals”. Jython is going to interpret “15.4” with double precision, while the DB will do the interpretation in the same type as COLUMNX (because it knows). Since 0.4 is a repeating fraction in binary, details of the bits of precision matters, as the roundoff can yield very small differences. Too small for humans, but enough to make what appears to be equal, not.

Bottom line: don’t compare any floating point values for “equals”. Fundamental implementation details make it unreliable.

oh right, I hadn’t thought of that, so this is a problem