DBZ-6990 Use DB2 specif statement for table truncation
This commit is contained in:
parent
3bc252871f
commit
5450b748a3
@ -326,7 +326,7 @@ private void writeTruncate(String sql, SinkRecordDescriptor record) throws SQLEx
|
||||
final Transaction transaction = session.beginTransaction();
|
||||
try {
|
||||
LOGGER.trace("SQL: {}", sql);
|
||||
final NativeQuery<?> query = session.createNativeQuery(sql);
|
||||
final NativeQuery<?> query = session.createNativeQuery(sql, Object.class);
|
||||
|
||||
query.executeUpdate();
|
||||
transaction.commit();
|
||||
|
@ -190,11 +190,13 @@ protected String resolveColumnNameFromField(String fieldName) {
|
||||
|
||||
@Override
|
||||
public String getTruncateStatement(TableDescriptor table) {
|
||||
String truncateStatement = super.getTruncateStatement(table);
|
||||
// For some reason the TRUNCATE statement doesn't work for DB2 even if it is supported from 9.7 https://www.ibm.com/support/pages/apar/JR37942
|
||||
// The problem verifies with Hibernate, plain JDBC works good.
|
||||
// Qlik uses the below approach https://community.qlik.com/t5/Qlik-Replicate/Using-Qlik-for-DB2-TRUNCATE-option/td-p/1989498
|
||||
final SqlStatementBuilder builder = new SqlStatementBuilder();
|
||||
builder.append(truncateStatement);
|
||||
builder.append(" IMMEDIATE");
|
||||
|
||||
builder.append("ALTER TABLE ");
|
||||
builder.append(getQualifiedTableName(table.getId()));
|
||||
builder.append(" ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE");
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user