In SQL Server Sono stato con il simbolo ^
, tuttavia, che non sembra funzionare in Oracle.bit esclusivo in Oracle
Come si fa un'esclusiva bit per bit OR
in Oracle?
In SQL Server Sono stato con il simbolo ^
, tuttavia, che non sembra funzionare in Oracle.bit esclusivo in Oracle
Come si fa un'esclusiva bit per bit OR
in Oracle?
Dalla documentazione:
function bitor(p1 number, p2 number) return number is
begin
return p1-bitand(p1,p2)+p2;
end;
function bitxor(p1 number, p2 number) return number is
begin
return bitor(p1,p2)-bitand(p1,p2);
end;
vedere che questi lavori, seguire la logica con solo 0 e 1 per input, e quindi non che non ci siano prestiti o carie.
- MarkusQ
No, l'articolo descrive come creare un UDF per BIT_OR, non è un'espressione standard. – Quassnoi
OK ... Grazie –
C'è l'operatore BITAND:
select bitand(49,54)+0 from dual;
È possibile build up the other operators da esso; e here.
Credo che non sia più necessario il +0 per ingannare il database. – orbfish
Non c'è un modo semplice.
Puoi lanciare stringa HEX
valori in RAW
valori e utilizzare UTL_RAW
:
SELECT UTL_RAW.bit_xor(HEXTORAW(TO_CHAR(1, 'FMX')), HEXTORAW(TO_CHAR(2, 'FMX')))
FROM dual
---
03
xor = p1-2 * bitand (p1, p2) + p2 – Akvel