Building null-checking expression without calling objectNode() twice?

From: Mike Kienenberger (mkienen..mail.com)
Date: Tue Aug 22 2006 - 12:31:09 EDT

  • Next message: Mike Kienenberger: "Re: Building null-checking expression without calling objectNode() twice?"

    I'm trying to build the ((exp is null) or (exp <> 'Y')) sql for an inequality.

    My thought was to stick the following code at the top of startNode,
    essentially calling the part of Expression.traverse(Expression,
    TraversalHandler) that generates the left-hand-side twice. Calling
    the code twice turns out to have bad side effects, like creating
    multiple joins.

            if (handleNullInequalityComparison)
            {
                qualBuf.append("((");

                Object child = node.getOperand(0);
                if (child instanceof Expression) {
                    Expression childExp = (Expression) child;
                    childExp.traverse(node, this);
                }
                else {
                    this.objectNode(child, node);
                }

                qualBuf.append(" IS NULL) OR ");
            }

    So I guess what I need to do is call it once and then cache the value.
       I'm trying to figure out the best way to do this as well as how to
    share the cached value since I can't store it in the Expression or the
    TraversalHandler instance.



    This archive was generated by hypermail 2.0.0 : Tue Aug 22 2006 - 12:31:32 EDT