Bitwise OR (|)
The bitwise OR operator performs a bitwise logical OR operation between two operands.
The bitwise OR compares two bits and assigns a value equal to 1 to the result if the values of either or both the bits are equal to 1. If neither bit in the input expressions has a value of 1, the bit in the result is set to 0. The OR operator can take only numeric values as its operands.
Syntax
expression | expression
Expression is any valid expression containing the integer data type, which is transformed into a binary number for the bitwise operation.
Values Returned
In a bitwise OR operation involving operands of different integer data types, the argument of the smaller data type is converted to the larger data type or to the data type that is immediately larger than the larger of the two operands. For example, when performing an OR operation involving smallint and integer, the smallint expression is converted to integer.
If any of the operands involved in a bitwise OR operation is signed, then the resultant value will also be signed.
Examples
This example first shows how to create a foreign key entry and a primary key entry in the X$Index table, then how to obtain a list of foreign and primary key constraints.
Execute of the following statements to create two entries in the X$Index table (one for a foreign key and one for a primary key).
CREATE TABLE Employee
(
empid IDENTITY NOT NULL PRIMARY KEY, -- Employee ID
empname VARCHAR(50) NOT NULL, -- Name of employee
supid INTEGER NULL -- Id of supervisor
)
 
ALTER TABLE Employee
ADD CONSTRAINT SupIdMustBeValid
FOREIGN KEY (supid) REFERENCES Employee(empid)
ON DELETE CASCADE
Execute the following to obtain a list of all foreign key and primary constraints on all tables in the database.
select B.Xf$Name "Table name", C.Xe$Name "Column name",
IF (Xi$Flags & 8192 = 0, 'Primary key', 'Foreign key') "Key type" from X$Index A, X$File B, X$Field C
where (A.Xi$Flags & (16384 | 8192)) > 0 AND
A.Xi$File = B.Xf$Id AND
A.Xi$Field = C.Xe$Id
The executed statement results in the following:
Employee empid Primary key
Employee supid Foreign key