use of liquibase.statement.UpdateExecutablePreparedStatement in project liquibase by liquibase.
the class UpdateDataChange method generateStatements.
@Override
public SqlStatement[] generateStatements(Database database) {
boolean needsPreparedStatement = false;
for (ColumnConfig column : getColumns()) {
if (column.getValueBlobFile() != null) {
needsPreparedStatement = true;
}
if (column.getValueClobFile() != null) {
needsPreparedStatement = true;
}
if ((database instanceof OracleDatabase) && (column.getType() != null) && "CLOB".equalsIgnoreCase(column.getType()) && (column.getValue() != null) && (column.getValue().length() >= 4000)) {
needsPreparedStatement = true;
}
final Object valueObject = column.getValueObject();
if (valueObject instanceof SequenceNextValueFunction) {
((SequenceNextValueFunction) valueObject).setSchemaName(this.getSchemaName());
}
if (valueObject instanceof SequenceCurrentValueFunction) {
((SequenceCurrentValueFunction) valueObject).setSchemaName(this.getSchemaName());
}
}
if (needsPreparedStatement) {
UpdateExecutablePreparedStatement statement = new UpdateExecutablePreparedStatement(database, catalogName, schemaName, tableName, columns, getChangeSet(), Scope.getCurrentScope().getResourceAccessor());
statement.setWhereClause(where);
for (ColumnConfig whereParam : whereParams) {
if (whereParam.getName() != null) {
statement.addWhereColumnName(whereParam.getName());
}
statement.addWhereParameter(whereParam.getValueObject());
}
return new SqlStatement[] { statement };
}
UpdateStatement statement = new UpdateStatement(getCatalogName(), getSchemaName(), getTableName());
for (ColumnConfig column : getColumns()) {
statement.addNewColumnValue(column.getName(), column.getValueObject());
}
statement.setWhereClause(where);
for (ColumnConfig whereParam : whereParams) {
if (whereParam.getName() != null) {
statement.addWhereColumnName(whereParam.getName());
}
statement.addWhereParameter(whereParam.getValueObject());
}
return new SqlStatement[] { statement };
}
Aggregations