开发者

Firebird - update row's value in table basing on some condition

开发者 https://www.devze.com 2023-04-10 20:13 出处:网络
As far as I remember I could do such update in MS SQL Server: UPDATE MyTable SET MyValue = (IF SomeCondition THEN 1 ELSE 0 END)

As far as I remember I could do such update in MS SQL Server:

UPDATE MyTable SET MyValue = (IF SomeCondition THEN 1 ELSE 0 END)

or different way for update by using CASE:

UPDATE MyTable  SET MyValue  = (CASE WHEN SomeCondition1 THEN 1 ELSE 0 END)

Is any of this methods possible in Firebird? I've tried both ways but with no luck.

Thank开发者_Python百科s for answers.


Which version of FireBird are you using? I tested with 2.5 and the second one (using CASE) works as expected.

FireBird doesn't support IF statement in DSQL but you can use IIF internal function, ie following works too:

UPDATE MyTable SET MyValue = iif(SomeCondition, 1, 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号