public abstract class PrepareAttributeColumns extends CreateDatabaseObjectsAction
Upgrade actions that extend this class typically run during the pre-upgrade phase.
NOLOG
CONTINUE_ON_ERROR, m_defaultOptions, m_options
APPEND_LOG, DATABASE_TYPE, DATABASE_URL, DB_USER_NAME, DB_USER_PASSWORD, DOMAIN_TYPE, ENABLE_SSL_SUPPORT, FOR_SCHEMA_UPGRADE, IFS_DOMAIN_DISPLAY_NAME, IFS_DOMAIN_NAME, IFS_SCHEMA_NAME, IFS_SCHEMA_PASSWORD, IFS_SERVICE_NAME, IFS_USER_NAME, IFS_USER_PASSWORD, INCLUDE_PATH, INITIAL_CONTEXT_FACTORY, LDAP_URL_DAS_LOOKUP, LDAP_USER_NAME, LDAP_USER_PASSWORD, OUTPUT_FILE, PARAMETER_FILE, REGISTRY, SCHEMA_VERSION_KEY, SECURITY_PROTOCOL_NAME, SERVICE_CONFIGURATION_NAME
Constructor and Description |
---|
PrepareAttributeColumns() |
Modifier and Type | Method and Description |
---|---|
void |
addAttributeColumnIfNecessary(Connection conn,
String tableName,
String columnName,
String rdbmsDataType)
Alter the specified table to add a new column in preparation for adding
an attribute later that uses it.
|
protected String |
getPrimaryKeyColumn()
Return the first primary key column.
|
protected String[] |
getPrimaryKeyColumns()
Return the array of the columns comprising the primary key.
|
protected abstract String |
getSelectConditionSql()
Return the SQL string used as the condition to select rows for update.
|
protected String |
getSelectSql()
Return the SQL used to select a batch of rows.
|
protected abstract String |
getTableName()
Return the name of the table being updated.
|
protected abstract String |
getUpdateColumnsSql()
Return the SQL string used to set new values in the update statement.
|
protected String |
getUpdateSql()
Return the SQL used to update each row.
|
void |
initializeAttributeColumns(Connection conn,
int batchSize)
Initialize the newly added columns by selecting and updating rows in
batches.
|
protected List<long[]> |
selectPrimaryKeyBatch(Connection conn,
long lastId,
int batchSize)
Select a batch of Primary Keys for rows that need to be updated.
|
analyze, analyzeTable, closeResultSet, closeStatement, columnExists, commit, createIndex, createIndex, createIndex, createIndex, createIndex, createIndex, createSequence, createTable, createView, dropIndex, dropSequence, dropTable, dropView, executeStatement, executeUpdate, failed, getNextSequenceValue, getSchemaName, getTimestamp, isValidConnection, log, log, printStackTrace, rollback, rowExists, rowExists, stop, tableExists
execute, perform, setDatabaseUrl, setPassword, setUser
getDescription, getName, getValue, isContinueOnError, isPostgres, putValue, setDefaultOptions, setDescription, setName, setOptions
public void addAttributeColumnIfNecessary(Connection conn, String tableName, String columnName, String rdbmsDataType) throws SQLException
conn
- database connectiontableName
- the table name for the classobject involvedcolumnName
- the name of the new column to addrdbmsDataType
- the DBMS data type string (e.g. "NUMBER(20)" )SQLException
- if the operation failspublic void initializeAttributeColumns(Connection conn, int batchSize) throws SQLException
The caller must implement the following methods:
conn
- database connectionbatchSize
- the maximum number of rows to select in each batchSQLException
- if the operation failsprotected List<long[]> selectPrimaryKeyBatch(Connection conn, long lastId, int batchSize) throws SQLException
conn
- database connectionlastId
- the last Primary key processed, included in the query
to only process IDs greater (or equal) than this valuebatchSize
- the maximum number of rows to be selectedSQLException
- if the operation failsprotected String getSelectSql()
protected String getUpdateSql()
protected String getPrimaryKeyColumn()
The implementation here returns "id". Subclasses may override. Must be a column with a data type of NUMBER.
protected String[] getPrimaryKeyColumns()
The implementation here returns a length 1 array containing the value
returned from getPrimaryKeyColumn
.
protected abstract String getTableName()
protected abstract String getSelectConditionSql()
Must not contain any bind variables, and must be a legal SQL boolean
expression. If no condition is desired, must return something equivalent
to "1 = 1".
For example:
"POLICYLISTS is null"
protected abstract String getUpdateColumnsSql()
For example:
"POLICYLISTS = 0, STORAGEGROUP = 0"
Copyright © 2023. All rights reserved.