use of org.h2.util.StatementBuilder in project h2database by h2database.
the class LinkedIndex method remove.
@Override
public void remove(Session session, Row row) {
ArrayList<Value> params = New.arrayList();
StatementBuilder buff = new StatementBuilder("DELETE FROM ");
buff.append(targetTableName).append(" WHERE ");
for (int i = 0; i < row.getColumnCount(); i++) {
buff.appendExceptFirst("AND ");
Column col = table.getColumn(i);
buff.append(col.getSQL());
Value v = row.getValue(i);
if (isNull(v)) {
buff.append(" IS NULL ");
} else {
buff.append('=');
addParameter(buff, col);
params.add(v);
buff.append(' ');
}
}
String sql = buff.toString();
try {
PreparedStatement prep = link.execute(sql, params, false);
int count = prep.executeUpdate();
link.reusePreparedStatement(prep, sql);
rowCount -= count;
} catch (Exception e) {
throw TableLink.wrapException(sql, e);
}
}
use of org.h2.util.StatementBuilder in project h2database by h2database.
the class IndexCondition method compareTypeToString.
private static String compareTypeToString(int i) {
StatementBuilder s = new StatementBuilder();
if ((i & EQUALITY) == EQUALITY) {
s.appendExceptFirst("&");
s.append("EQUALITY");
}
if ((i & START) == START) {
s.appendExceptFirst("&");
s.append("START");
}
if ((i & END) == END) {
s.appendExceptFirst("&");
s.append("END");
}
if ((i & ALWAYS_FALSE) == ALWAYS_FALSE) {
s.appendExceptFirst("&");
s.append("ALWAYS_FALSE");
}
if ((i & SPATIAL_INTERSECTS) == SPATIAL_INTERSECTS) {
s.appendExceptFirst("&");
s.append("SPATIAL_INTERSECTS");
}
return s.toString();
}
use of org.h2.util.StatementBuilder in project h2database by h2database.
the class ValueArray method getSQL.
@Override
public String getSQL() {
StatementBuilder buff = new StatementBuilder("(");
for (Value v : values) {
buff.appendExceptFirst(", ");
buff.append(v.getSQL());
}
if (values.length == 1) {
buff.append(',');
}
return buff.append(')').toString();
}
use of org.h2.util.StatementBuilder in project h2database by h2database.
the class ValueArray method getTraceSQL.
@Override
public String getTraceSQL() {
StatementBuilder buff = new StatementBuilder("(");
for (Value v : values) {
buff.appendExceptFirst(", ");
buff.append(v == null ? "null" : v.getTraceSQL());
}
return buff.append(')').toString();
}
use of org.h2.util.StatementBuilder in project h2database by h2database.
the class TriggerObject method getTypeNameList.
public String getTypeNameList() {
StatementBuilder buff = new StatementBuilder();
if ((typeMask & Trigger.INSERT) != 0) {
buff.appendExceptFirst(", ");
buff.append("INSERT");
}
if ((typeMask & Trigger.UPDATE) != 0) {
buff.appendExceptFirst(", ");
buff.append("UPDATE");
}
if ((typeMask & Trigger.DELETE) != 0) {
buff.appendExceptFirst(", ");
buff.append("DELETE");
}
if ((typeMask & Trigger.SELECT) != 0) {
buff.appendExceptFirst(", ");
buff.append("SELECT");
}
if (onRollback) {
buff.appendExceptFirst(", ");
buff.append("ROLLBACK");
}
return buff.toString();
}
Aggregations