public void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec) { final SqlWriter.Frame frame = writer.startFunCall(getName()); operands[0].unparse(writer, leftPrec, rightPrec); writer.sep("PLACING"); operands[1].unparse(writer, leftPrec, rightPrec); writer.sep("FROM"); operands[2].unparse(writer, leftPrec, rightPrec); if (4 == operands.length) { writer.sep("FOR"); operands[3].unparse(writer, leftPrec, rightPrec); } writer.endFunCall(frame); }
public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { final SqlWriter.Frame frame = writer.startFunCall(getName()); call.operand(0).unparse(writer, leftPrec, rightPrec); writer.sep("FROM"); call.operand(1).unparse(writer, leftPrec, rightPrec); writer.endFunCall(frame); }
public void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec) { final SqlWriter.Frame frame = writer.startList(BetweenFrameType, "", ""); operands[VALUE_OPERAND].unparse(writer, getLeftPrec(), 0); writer.sep(getName()); operands[SYMFLAG_OPERAND].unparse(writer, 0, 0); // If the expression for the lower bound contains a call to an AND // operator, we need to wrap the expression in parentheses to prevent // the AND from associating with BETWEEN. For example, we should // unparse // a BETWEEN b OR (c AND d) OR e AND f // as // a BETWEEN (b OR c AND d) OR e) AND f // If it were unparsed as // a BETWEEN b OR c AND d OR e AND f // then it would be interpreted as // (a BETWEEN (b OR c) AND d) OR (e AND f) // which would be wrong. int lowerPrec = new AndFinder().containsAnd(operands[LOWER_OPERAND]) ? 100 : 0; operands[LOWER_OPERAND].unparse(writer, lowerPrec, lowerPrec); writer.sep("AND"); operands[UPPER_OPERAND].unparse(writer, 0, getRightPrec()); writer.endList(frame); }