com.ptc.windchill.upgrade.directives.postmigschemaupgrade
Class ModifyColumnNotNull

java.lang.Object
  extended bycom.ptc.windchill.upgrade.directives.postmigschemaupgrade.ModifyColumnNotNull
All Implemented Interfaces:
UpdateDirective

public class ModifyColumnNotNull
extends Object
implements UpdateDirective

Alters a table to redeclare a column as not null if it is not already. The directive will not produce an error for columns that are already declared NOT NULL.

Format

    >ModifyColumnNotNull tableName="..." columnName="..."/<
 
Component Description Required Parameterizable
Attribute tableName The table to alter. yes yes, {Class}
Attribute tableName The column to modify. yes yes, {ColumnDescriptor:...}

Example Usage

    >ModifyColumnNotNull tableName="SomeExistingTable" columnName="IDA3D2"/<
 


Field Summary
static String COLUMN_NAME_ATTRIBUTE_NAME
           
private  ParameterizedString columnName_
           
private static String findObjectsDependentUponTable__
           
static String TABLE_NAME_ATTRIBUTE_NAME
           
private  ParameterizedString tableName_
           
 
Constructor Summary
ModifyColumnNotNull()
          Create an instance with empty table name and column name.
 
Method Summary
 void asDomOn(Element element)
          Writes the attributes as described in the class documentation above.
 void execute(DirectiveServices directive_services)
           
private static boolean executeSqlUpdate(String sql, Connection connection)
          Execute the update statement, but do not report any ORA-01442 errors.
private  String getDirectiveName()
           
 void initializeFromDom(Element element)
          Reads from DOMs formatted as described in the class documentation above.
private static void recompileDependentObjects(String table_name, Connection connection)
           
 void setColumnName(String column_name)
          Sets the column name to alter.
static void setNullability(Connection connection, String table_name, String column_name, boolean nullable)
          Change the column constraint on a table's column to NULL or NOT NULL based on the value of the nullable parameter.
 void setTableName(String table_name)
          Sets the table name to alter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME_ATTRIBUTE_NAME

public static final String TABLE_NAME_ATTRIBUTE_NAME
See Also:
Constant Field Values

COLUMN_NAME_ATTRIBUTE_NAME

public static final String COLUMN_NAME_ATTRIBUTE_NAME
See Also:
Constant Field Values

findObjectsDependentUponTable__

private static String findObjectsDependentUponTable__

tableName_

private ParameterizedString tableName_

columnName_

private ParameterizedString columnName_
Constructor Detail

ModifyColumnNotNull

public ModifyColumnNotNull()
Create an instance with empty table name and column name. These names must be set before executing the directive.

Method Detail

setTableName

public void setTableName(String table_name)
                  throws ParseException
Sets the table name to alter. The table name can be parameterized to class info. If this is done, the directive needs to be placed inside a directive that provides parameterization information such as ForEachConcreteImplementorOf.

Throws:
ParseException - if the table name contains a parameterization as allowed in ParameterizedStrings, but it is syntactically incorrect or utilizes a macro incorrectly
See Also:
ForEachConcreteImplementorOf

setColumnName

public void setColumnName(String column_name)
                   throws ParseException
Sets the column name to alter. The table name can be parameterized to class info. If this is done, the directive needs to be placed inside a directive that provides parameterization information such as ForEachConcreteImplementorOf.

Throws:
ParseException - if the table name contains a parameterization as allowed in ParameterizedStrings, but it is syntactically incorrect or utilizes a macro incorrectly
See Also:
ForEachConcreteImplementorOf

asDomOn

public void asDomOn(Element element)
Writes the attributes as described in the class documentation above.

Specified by:
asDomOn in interface UpdateDirective

initializeFromDom

public void initializeFromDom(Element element)
                       throws DirectiveIOException
Reads from DOMs formatted as described in the class documentation above.

Specified by:
initializeFromDom in interface UpdateDirective
Throws:
DirectiveIOException - if one(or both) of the attributes is missing or if it is written as a parameterized attribute and contains a syntax error

execute

public void execute(DirectiveServices directive_services)
             throws DirectiveExecutionException
Specified by:
execute in interface UpdateDirective
Throws:
DirectiveExecutionException

setNullability

public static void setNullability(Connection connection,
                                  String table_name,
                                  String column_name,
                                  boolean nullable)
                           throws DirectiveExecutionException
Change the column constraint on a table's column to NULL or NOT NULL based on the value of the nullable parameter. The This code will not fail if the table's column constraint is already set as specified.

This is a generic, reusable static method that is used by this directivec but which can also be used by other code, provided that they supply the JDBC connection.

Throws:
DirectiveExecutionException

recompileDependentObjects

private static void recompileDependentObjects(String table_name,
                                              Connection connection)
                                       throws DirectiveExecutionException
Throws:
DirectiveExecutionException

executeSqlUpdate

private static boolean executeSqlUpdate(String sql,
                                        Connection connection)
                                 throws DirectiveExecutionException
Execute the update statement, but do not report any ORA-01442 errors.

Returns:
true if the execution succeeded, false if it failed with an acceptable ORA error, tosses exception otherwise.
Throws:
DirectiveExecutionException - for all other ora errors

getDirectiveName

private String getDirectiveName()