use of org.jkiss.dbeaver.ext.db2.model.DB2TableColumn in project dbeaver by serge-rider.
the class DB2TableColumnManager method createDatabaseObject.
// ------
// Create
// ------
@Override
protected DB2TableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, DB2TableBase parent, Object copyFrom) {
DB2TableColumn column = new DB2TableColumn(parent);
column.setName(getNewColumnName(monitor, context, parent));
return column;
}
use of org.jkiss.dbeaver.ext.db2.model.DB2TableColumn in project dbeaver by serge-rider.
the class DB2TableColumnManager method addObjectModifyActions.
// -----
// Alter
// -----
@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
DB2TableColumn db2Column = command.getObject();
boolean hasColumnChanges = false;
if (!command.getProperties().isEmpty()) {
final String deltaSQL = computeDeltaSQL(command);
if (!deltaSQL.isEmpty()) {
hasColumnChanges = true;
String sqlAlterColumn = String.format(SQL_ALTER, db2Column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sqlAlterColumn));
}
}
// Comment
DBEPersistAction commentAction = buildCommentAction(db2Column);
if (commentAction != null) {
actionList.add(commentAction);
}
if (hasColumnChanges) {
// Be Safe, Add a reorg action
actionList.add(buildReorgAction(db2Column));
}
}
use of org.jkiss.dbeaver.ext.db2.model.DB2TableColumn in project dbeaver by serge-rider.
the class DB2TableUniqueKeyCache method fetchObjectRow.
@Nullable
@Override
protected DB2TableKeyColumn[] fetchObjectRow(JDBCSession session, DB2Table db2Table, DB2TableUniqueKey object, JDBCResultSet dbResult) throws SQLException, DBException {
String colName = JDBCUtils.safeGetString(dbResult, "COLNAME");
DB2TableColumn tableColumn = db2Table.getAttribute(session.getProgressMonitor(), colName);
if (tableColumn == null) {
log.debug("Column '" + colName + "' not found in table '" + db2Table.getFullyQualifiedName(DBPEvaluationContext.UI) + "' ??");
return null;
} else {
return new DB2TableKeyColumn[] { new DB2TableKeyColumn(object, tableColumn, JDBCUtils.safeGetInt(dbResult, "COLSEQ")) };
}
}
use of org.jkiss.dbeaver.ext.db2.model.DB2TableColumn in project dbeaver by serge-rider.
the class DB2TableCheckConstraintCache method fetchObjectRow.
@Nullable
@Override
protected DB2TableCheckConstraintColumn[] fetchObjectRow(JDBCSession session, DB2Table db2Table, DB2TableCheckConstraint object, JDBCResultSet dbResult) throws SQLException, DBException {
String colName = JDBCUtils.safeGetString(dbResult, "COLNAME");
DB2TableColumn tableColumn = db2Table.getAttribute(session.getProgressMonitor(), colName);
DB2TableCheckConstraintColUsage usage = CommonUtils.valueOf(DB2TableCheckConstraintColUsage.class, JDBCUtils.safeGetString(dbResult, "USAGE"));
if (tableColumn == null) {
log.debug("Column '" + colName + "' not found in table '" + db2Table.getFullyQualifiedName(DBPEvaluationContext.UI) + "' ??");
return null;
} else {
return new DB2TableCheckConstraintColumn[] { new DB2TableCheckConstraintColumn(object, tableColumn, usage) };
}
}
use of org.jkiss.dbeaver.ext.db2.model.DB2TableColumn in project dbeaver by serge-rider.
the class DB2TableReferenceCache method fetchObjectRow.
@Nullable
@Override
protected DB2TableKeyColumn[] fetchObjectRow(JDBCSession session, DB2Table db2Table, DB2TableReference db2TableReference, JDBCResultSet dbResult) throws SQLException, DBException {
String colName = JDBCUtils.safeGetString(dbResult, "COLNAME");
DB2TableColumn tableColumn = db2Table.getAttribute(session.getProgressMonitor(), colName);
if (tableColumn == null) {
log.debug("DB2TableReferenceCache : Column '" + colName + "' not found in table '" + db2Table.getName() + "' ??");
return null;
} else {
return new DB2TableKeyColumn[] { new DB2TableKeyColumn(db2TableReference, tableColumn, JDBCUtils.safeGetInt(dbResult, "COLSEQ")) };
}
}
Aggregations