Append the string containing the SQL insert string for the given table.
SQLCall call = new SQLCall();
call.returnNothing();
Writer writer = new CharArrayWriter(200);
try {
writer.write("INSERT ");
writer.write("INTO ");
writer.write(getTable().getQualifiedName());
writer.write(" (");
Vector fieldsForTable = new Vector();
for (Enumeration fieldsEnum = getModifyRow().keys(); fieldsEnum.hasMoreElements();) {
DatabaseField field = (DatabaseField)fieldsEnum.nextElement();
if (field.getTable().equals(getTable()) || (!field.hasTableName())) {
fieldsForTable.addElement(field);
}
}
if (fieldsForTable.isEmpty()) {
throw QueryException.objectToInsertIsEmpty(getTable());
}
for (int i = 0; i < fieldsForTable.size(); i++) {
writer.write(((DatabaseField)fieldsForTable.elementAt(i)).getName());
if ((i + 1) < fieldsForTable.size()) {
writer.write(", ");
}
}
writer.write(") VALUES (");
for (int i = 0; i < fieldsForTable.size(); i++) {
DatabaseField field = (DatabaseField)fieldsForTable.elementAt(i);
call.appendModify(writer, field);
if ((i + 1) < fieldsForTable.size()) {
writer.write(", ");
}
}
writer.write(")");
call.setSQLString(writer.toString());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
return call;