在Oracle DB中通过SQL更新标志字段 [英] Updating a flags field by SQL in Oracle DB

查看:84
本文介绍了在Oracle DB中通过SQL更新标志字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在努力使我们的产品与Oracle兼容.到目前为止,我们支持MS Access和SQL Server.我们正在寻找与以下产品等效的Oracle:

We are trying to make our product compatible with Oracle. Upto now, we support MS Access and SQL Server. We are searching for the Oracle equivalent of:

SQL Server:
UPDATE MyTable SET MyColumn = MyColumn & ~ 256


Access:
UPDATE MyTable SET MyColumn = MyColumn BAND BNOT 256


推荐答案

最终,我发现了一个有用的Google搜索词(+ oracle + number + xor),然后发现Oracle只有一个数字的逻辑运算符:BITAND.借助BITAND和一些数学运算,可以计算其他运算符(另请参见 http://database.itags.org/oracle/22028/ [ ^ ])
因此,解决方案是:
Eventually I discovered a useful search term for Google (+oracle +number +xor) and then found out that Oracle has only one logical operator for numbers: BITAND. With BITAND and some math, other operators can be calculated (see also http://database.itags.org/oracle/22028/[^])
Hence, the solution is:
Oracle:
UPDATE MyTable SET MyColumn = BITAND(MyColumn, (-1 -256))


这篇关于在Oracle DB中通过SQL更新标志字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆