From the comments:
currentcredit is null before the update, what should i do
Ah, that's the problem then. In SQL, null
is sticky. null
+ anything is: null
. If this was TSQL (i.e. SQL Server), the solution would be ISNULL
:
UPDATE sd32depart SET currentcredit = ISNULL(currentcredit,0) + ?
where the result of ISNULL(x, y)
is x
if x
is non-null, otherwise y
. In C# terms, it is the equivalent of x ?? y
(and indeed, ISNULL(x, y)
is identical to COALESCE(x, y)
, except that COALESCE
is varadic).
So: find the informix equivalent of ISNULL
or COALESCE
, and use that.
From a brief search, it seems that in informix the NVL
function does this, so try:
UPDATE sd32depart SET currentcredit = NVL(currentcredit,0) + ?