UPDATE parking_lot_enclosed
SET free_berth = (
CASE
WHEN free_berth > 0 THEN (free_berth - 1)
ELSE 0
END
)
WHERE
1=1
and pl_no = #{plNo}
UPDATE parking_lot_enclosed
SET free_berth = (
CASE
WHEN free_berth < #{berthNum,jdbcType=INTEGER} THEN (free_berth + 1)
ELSE #{berthNum}
END
)
WHERE
1=1
and pl_no = #{plNo}