Case doesn't accept Begin
I need to update 2 separate fields in one case, something like below
UPDATE PYR SET
MSR =
Case
When MSR = :WRKH then
Begin
MSR = NULL
WRKDAY = WRKDAY -1
end;
end;
This is invalid syntax, and will not work. You seem to think a
CASEis like anIFin PSQL (Firebird's procedural language), but it is not. It is also not how theUPDATEsyntax works.CASEis a conditional value expression, and it can only return one value.The correct update statement would be putting the condition in the WHERE clause (as also suggested by Iłya Bursov in the comments):
If this is part of a more complex statement that also updates other fields, you need to write the conditions per field:
or (using
NULLIFto simplify)