servers.clear();
}
}
private String getPlanSQL(boolean insertFromSelect, boolean sortedInsertMode, Set<Map.Entry<String, List<String>>> regions) {
StatementBuilder buff = new StatementBuilder();
boolean first = true;
for (Map.Entry<String, List<String>> entry : regions) {
if (!first) {
buff.append(";");
buff.append('\n');
} else {
first = false;
}
buff.append("IN THE REGION ");
buff.append(StringUtils.quoteStringSQL(entry.getKey()));
buff.append('\n');
if (isInsert)
buff.append("INSERT INTO ");
else
buff.append("MERGE INTO ");
buff.append(table.getSQL()).append('(');
buff.resetCount();
for (Column c : columns) {
buff.appendExceptFirst(", ");
buff.append(c.getSQL());
}
buff.append(")\n");
if (isInsert) {
if (insertFromSelect) {
buff.append("DIRECT ");
}
if (sortedInsertMode) {
buff.append("SORTED ");
}
} else {
if (keys != null) {
buff.append(" KEY(");
buff.resetCount();
for (Column c : keys) {
buff.appendExceptFirst(", ");
buff.append(c.getSQL());
}
buff.append(")\n");
}
}
buff.append("VALUES ");
int row = 0;
if (entry.getValue().size() > 1) {
buff.append('\n');
}
for (String value : entry.getValue()) {
if (row++ > 0) {
buff.append(",\n");
}
buff.append(value);
}
}
return buff.toString();
}