use of com.wplatform.ddal.command.Prepared in project jdbc-shards by wplatform.
the class ExecuteProcedure method setParameters.
private void setParameters() {
Prepared prepared = procedure.getPrepared();
ArrayList<Parameter> params = prepared.getParameters();
for (int i = 0; params != null && i < params.size() && i < expressions.size(); i++) {
Expression expr = expressions.get(i);
Parameter p = params.get(i);
p.setValue(expr.getValue(session));
}
}
use of com.wplatform.ddal.command.Prepared in project jdbc-shards by wplatform.
the class MergeExecutor method merge.
private void merge(Row row) {
TableMate table = castTableMate(prepared.getTable());
Prepared update = prepared.getUpdate();
Column[] columns = prepared.getColumns();
Column[] keys = prepared.getKeys();
ArrayList<Parameter> k = update.getParameters();
for (int i = 0; i < columns.length; i++) {
Column col = columns[i];
Value v = row.getValue(col.getColumnId());
Parameter p = k.get(i);
p.setValue(v);
}
for (int i = 0; i < keys.length; i++) {
Column col = keys[i];
Value v = row.getValue(col.getColumnId());
if (v == null) {
throw DbException.get(ErrorCode.COLUMN_CONTAINS_NULL_VALUES_1, col.getSQL());
}
Parameter p = k.get(columns.length + i);
p.setValue(v);
}
int count = update.update();
if (count == 0) {
try {
table.validateConvertUpdateSequence(session, row);
updateRow(table, row);
} catch (DbException e) {
throw e;
}
} else if (count != 1) {
throw DbException.get(ErrorCode.DUPLICATE_KEY_1, table.getSQL());
}
}
use of com.wplatform.ddal.command.Prepared in project jdbc-shards by wplatform.
the class ExecuteProcedure method query.
@Override
public ResultInterface query(int limit) {
setParameters();
Prepared prepared = procedure.getPrepared();
return prepared.query(limit);
}
use of com.wplatform.ddal.command.Prepared in project jdbc-shards by wplatform.
the class ExecuteProcedure method update.
@Override
public int update() {
setParameters();
Prepared prepared = procedure.getPrepared();
return prepared.update();
}
use of com.wplatform.ddal.command.Prepared in project jdbc-shards by wplatform.
the class ReplaceExecutor method update.
private int update(Row row) {
Prepared update = prepared.getUpdate();
Column[] columns = prepared.getColumns();
Column[] keys = prepared.getKeys();
// the statement degenerates to an INSERT
if (update == null) {
return 0;
}
ArrayList<Parameter> k = update.getParameters();
for (int i = 0; i < columns.length; i++) {
Column col = columns[i];
Value v = row.getValue(col.getColumnId());
Parameter p = k.get(i);
p.setValue(v);
}
for (int i = 0; i < keys.length; i++) {
Column col = keys[i];
Value v = row.getValue(col.getColumnId());
if (v == null) {
throw DbException.get(ErrorCode.COLUMN_CONTAINS_NULL_VALUES_1, col.getSQL());
}
Parameter p = k.get(columns.length + i);
p.setValue(v);
}
return update.update();
}
Aggregations