在Oracle DB中通过SQL更新标志字段

在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))