Search in sources :

Example 6 with DB2TableColumn

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;
}
Also used : DB2TableColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableColumn)

Example 7 with DB2TableColumn

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));
    }
}
Also used : DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) DB2TableColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 8 with DB2TableColumn

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")) };
    }
}
Also used : DB2TableKeyColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableKeyColumn) DB2TableColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableColumn) Nullable(org.jkiss.code.Nullable)

Example 9 with DB2TableColumn

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) };
    }
}
Also used : DB2TableColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableColumn) DB2TableCheckConstraintColUsage(org.jkiss.dbeaver.ext.db2.model.dict.DB2TableCheckConstraintColUsage) DB2TableCheckConstraintColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableCheckConstraintColumn) Nullable(org.jkiss.code.Nullable)

Example 10 with DB2TableColumn

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")) };
    }
}
Also used : DB2TableKeyColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableKeyColumn) DB2TableColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableColumn) Nullable(org.jkiss.code.Nullable)

Aggregations

DB2TableColumn (org.jkiss.dbeaver.ext.db2.model.DB2TableColumn)9 Nullable (org.jkiss.code.Nullable)4 DB2TableKeyColumn (org.jkiss.dbeaver.ext.db2.model.DB2TableKeyColumn)3 DB2Schema (org.jkiss.dbeaver.ext.db2.model.DB2Schema)2 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 DBException (org.jkiss.dbeaver.DBException)1 DB2ObjectType (org.jkiss.dbeaver.ext.db2.editors.DB2ObjectType)1 DB2DataSource (org.jkiss.dbeaver.ext.db2.model.DB2DataSource)1 DB2Index (org.jkiss.dbeaver.ext.db2.model.DB2Index)1 DB2Package (org.jkiss.dbeaver.ext.db2.model.DB2Package)1 DB2Routine (org.jkiss.dbeaver.ext.db2.model.DB2Routine)1 DB2Sequence (org.jkiss.dbeaver.ext.db2.model.DB2Sequence)1 DB2Table (org.jkiss.dbeaver.ext.db2.model.DB2Table)1 DB2TableBase (org.jkiss.dbeaver.ext.db2.model.DB2TableBase)1 DB2TableCheckConstraintColumn (org.jkiss.dbeaver.ext.db2.model.DB2TableCheckConstraintColumn)1 DB2Tablespace (org.jkiss.dbeaver.ext.db2.model.DB2Tablespace)1 DB2Variable (org.jkiss.dbeaver.ext.db2.model.DB2Variable)1 DB2XMLSchema (org.jkiss.dbeaver.ext.db2.model.DB2XMLSchema)1 DB2RoutineType (org.jkiss.dbeaver.ext.db2.model.dict.DB2RoutineType)1 DB2TableCheckConstraintColUsage (org.jkiss.dbeaver.ext.db2.model.dict.DB2TableCheckConstraintColUsage)1