Parity

From Oracle FAQ

Jump to: navigation, search

Parity is an error detection scheme that uses an extra checking bit, called the parity bit, to allow the receiver to verify that the data is error free.

Examples

Here is a sample PL/SQL function that simulates parity calculation:

CREATE OR REPLACE FUNCTION parity(b1 CHAR, b2 CHAR, b3 CHAR, b4 CHAR,
                                  b5 CHAR, b6 CHAR, b7 CHAR, b8 CHAR)
RETURN CHAR IS
BEGIN
   RETURN utl_raw.bit_xor(utl_raw.bit_xor(utl_raw.bit_xor(utl_raw.bit_xor(
          utl_raw.bit_xor(utl_raw.bit_xor(utl_raw.bit_xor(
          b1, b2), b3), b4), b5), b6), b7), b8);
END;
/

SELECT parity('11111111', '10101010', '01010101', '00000000',
              '11001100', '00110011', '00011101', '11100010')
  FROM dual;

Go ahead and test it, if any single input value is lost, it can be recalculated with the parity byte and the above parity function.

Also see


Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #
Personal tools