The following logical operators functions take one Boolean sequence argument input, or two Boolean input sequences, left and right, and produce the Boolean result sequence.
If the two input sequence arguments are of different lengths the operation will be performed on only the number of elements in the shorter of the two sequences.
seq_not( input ) The element of the result sequence is the logical not of the corresponding element in input seq_and( left, right ) The element of the result sequence is the logical and of the corresponding elements in left and right seq_or( left, right ) The element of the result sequence is the logical or of the corresponding elements in left and right seq_xor( left, right ) The element of the result sequence is the logical exclusive or of the corresponding elements in left and right Example
Following is an example code snippet demonstrating the logical operator functions:
-- seq_not, seq_and, seq_or, seq_xor INSERT INTO SimpleSequence(testNumber,bVal1,bVal2) VALUES(4,'{1,1,0,0}','{1,0,1,0}'); SELECT bVal2,seq_not(bVal2) AS "not" FROM SimpleSequence WHERE testNumber=4; SELECT bVal1,bVal2,seq_and(bVal1,bVal2) AS "and" FROM SimpleSequence WHERE testNumber=4; SELECT bVal1,bVal2,seq_or(bVal1,bVal2) AS "or" FROM SimpleSequence WHERE testNumber=4; SELECT bVal1,bVal2,seq_xor(bVal1,bVal2) AS "xor" FROM SimpleSequence WHERE testNumber=4; bVal2{} not{} -------------------------------------------- {1, 0, 1, 0} {0, 1, 0, 1} bVal1{} bVal2{} and{} -------------------------------------------- {1, 1, 0, 0} {1, 0, 1, 0} {1, 0, 0, 0} bVal1{} bVal2{} or{} -------------------------------------------- {1, 1, 0, 0} {1, 0, 1, 0} {1, 1, 1, 0} bVal1{} bVal2{} xor{} -------------------------------------------- {1, 1, 0, 0} {1, 0, 1, 0} {0, 1, 1, 0}