int keysPerBatch = 20;
boolean succeeded = false;
for (int tries = 0; !succeeded && tries < 2; tries++) {
while (results.count() < count) {
try {
<BUG>StringBuffer sql = new StringBuffer();
</BUG>
sql.append("SELECT ");
for (int keyBatchNum = Math.min(keysPerBatch, count - results.count()) - 1; keyBatchNum >= 0; keyBatchNum --) {
sql.append("NEXTVAL('" + sequenceName + "') AS KEY" + keyBatchNum);

int keysPerBatch = 20;
boolean succeeded = false;
for (int tries = 0; !succeeded && tries < 2; tries++) {
while (results.count() < count) {
try {
StringBuilder sql = new StringBuilder();
sql.append("SELECT ");
for (int keyBatchNum = Math.min(keysPerBatch, count - results.count()) - 1; keyBatchNum >= 0; keyBatchNum --) {
sql.append("NEXTVAL('" + sequenceName + "') AS KEY" + keyBatchNum);
