SQL Sequence And, Or and Xor Functions

The seq_not(), seq_and(), seq_or() and seq_xor() functions take two sequence arguments of type Boolean and return a sequence of type Boolean. These functions apply the indicated operation to the corresponding elements of two sequences.

Following is an example script demonstrating the seq_and(), seq_or() and seq_xor() functions:

 
    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}
         

Sample script

A sample script to demonstrate this select statement using xSQL can be run from the samples/xsql/scripts/financial directory with the following command:

     
    f 3