Subject Re: [firebird-support] Bug, Gotcha or SQL standard?
Author Pavel Menshchikov
Hello Peter,

t> I have the following SQL statements, dynamically created. The value
t> of 12 is for illustration purposes only:

t> UPDATE IBAT SET IB_QTY=IB_QTY-12 WHERE CODE='A'
t> UPDATE IBAT SET IB_QTY=IB_QTY-+12 WHERE CODE='A'

t> Both the above work fine. However:

t> UPDATE IBAT SET IB_QTY=IB_QTY--12 WHERE CODE='A'

t> does nothing whatsoever, no update, no exception, just nothing.

In fact, it updates all rows of IBAT, because double-dash (--) is a
single-line comment in SQL. AFAIR, that's SQL standard (I may be
wrong).

t> This works:
t> UPDATE IBAT SET IB_QTY=IB_QTY- -12 WHERE CODE='A'

Use round brackets for both positive and negative values when you
generate your SQL statements to avoid problems.


--
Best regards,
Pavel Menshchikov