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.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, 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); }
public void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec) { assert operands.length >= 2; final SqlWriter.Frame frame = writer.startList(SqlWriter.FrameTypeEnum.Simple); operands[0].unparse(writer, leftPrec, getLeftPrec()); final boolean needsSpace = true; writer.setNeedWhitespace(needsSpace); writer.sep("AS"); writer.setNeedWhitespace(needsSpace); operands[1].unparse(writer, getRightPrec(), rightPrec); if (operands.length > 2) { final SqlWriter.Frame frame1 = writer.startList(SqlWriter.FrameTypeEnum.Simple, "(", ")"); for (int i = 2; i < operands.length; i++) { SqlNode operand = operands[i]; writer.sep(",", false); operand.unparse(writer, 0, 0); } writer.endList(frame1); } writer.endList(frame); }