binaryExpression

binaryExpression(operator:     Integer;
                 leftOperand:  Object io;
                 rightOperand: Any io;
                 level:        Integer): Object;

The binaryExpression method of the JadeRelationalQueryProviderIF interface is called by the ODBC driver to allow the application to map a search predicate in the form of an expression tree onto its own internal representation. For a simple logical comparison (a binary expression), this interface method is called once.

More-complex expressions that combine predicates with logical operators require multiple calls.

When this method is called to map a logical comparison predicate, the value of the leftOperand parameter is the object that represents an attribute (a user object that implements the JadeRelationalAttributeIF interface, a property, or a method) and the value of the rightOperand parameter is a literal value or an object that represents an attribute. For example, if the WHERE clause is (name="John"), if name is a soft attribute, the left operand is the implementor of the JadeRelationalAttributeIF interface.

If the name value is a property, the left operand is the property instance for name. If the name value is a method, the left operand is the method instance for name. The value of the right operand is a string with the value "John".

The depth of the expression tree is indicated by the value of the level parameter.

When the binaryExpression method is called to map a logical operator (an AND or OR), the left and right operands are the object returned from a previous call to the binaryExpression method or the unaryExpression method, or an object that represents an attribute that has a Boolean value. For example, if the WHERE clause is (name = "John") AND (surname = "Jones"), the following calls are made.

binaryExpression(Op_Equal, <name attribute>, "John", 2);       // returns A
binaryExpression(Op_Equal, <surname attribute>, "Jones", 2);   // returns B
binaryExpression(Op_And, A, B, 1);                             // returns C

The expression represented by the object C is used to execute the query.

Your implementation of this method must delete any transient or persistent objects used in defining the expression. If the operand is an intermediate expression object, the implementation can delete the object before returning to the ODBC driver. If the implementation cannot represent the expression, it can return the null value, which instructs the ODBC driver to default to its own query execution plan.