psdi.configure

Class UpgDefaultsTemplate

  • java.lang.Object
    • psdi.configure.UpgDefaultsTemplate
  • All Implemented Interfaces:
    UpgConstants


    public abstract class UpgDefaultsTemplate
    extends java.lang.Object
    implements UpgConstants
    Template for Upgrade for providing default values for a column. Called from ConfigDB and Util.

    This is needed only when the column is non-nullable and the standard default values (No for YORN columns, 0 for numeric columns) are not sufficient. It is invoked when changing a column to not allow nulls, and when adding a column (whether or not it allows nulls).

    The subdirectory containing these extensions is determined as follows. Find the name of the maxvar MAXUPG from the database that you are converting from. Use the first part of the varvalue up to but not including any space or hyphen character. For example, if the varvalue equals V411-06 3/23/2001, then the name of the subdirectory would be psdi.configure.V411.

    See Also:
    ConfigDB.getUpgradeDefaultSql(java.lang.String, java.lang.String), Util.upgradeDefaultExists(java.lang.String, java.lang.String, java.lang.String)
    • Field Detail

      • tbname

        public java.lang.String tbname
        Table name
      • con

        public java.sql.Connection con
        Database connection
      • util

        public Util util
        Reference to Util class.
      • supportedColumns

        public java.lang.String[] supportedColumns
        Names of columns on this table for which default logic is provided. Column names should be uppercase.
    • Constructor Detail

      • UpgDefaultsTemplate

        public UpgDefaultsTemplate(java.lang.String tbname,
                                   java.sql.Connection con,
                                   Util util)
        Parameters:
        tbname - Table name
        con - Connection
        util - Util
    • Method Detail

      • getDefaultSql

        public java.util.ArrayList getDefaultSql(java.lang.String name)
                                          throws java.lang.Exception
        Return one or more sql statements for updating the specified column.
        Parameters:
        name - Column name
        Returns:
        sql statement(s) to update the specified column
        Throws:
        java.lang.Exception
      • getRenameSql

        public java.lang.String getRenameSql(java.lang.String tbname,
                                             java.lang.String oldColumn,
                                             java.lang.String newColumn,
                                             boolean onlyIfNull)
                                      throws java.lang.Exception
        Copy the values of one column to another column. Renaming a column is implemenetd as:
        1. Add new column
        2. Copy old column to new column
        3. Drop old columns
        Parameters:
        tbname - Name of the table
        oldColumn - Old name of the column
        newColumn - New name of the column
        onlyIfNull - Flag to indicate column should only be populated if it is empty.
        Returns:
        SQL statement to populate the new column
        Throws:
        java.lang.Exception
      • getRenameSql

        public java.lang.String getRenameSql(java.lang.String tbname,
                                             java.lang.String oldColumn,
                                             java.lang.String newColumn)
                                      throws java.lang.Exception
        Copy the values of one column to another column. Renaming a column is implemenetd as:
        1. Add new column
        2. Copy old column to new column
        3. Drop old columns
        Parameters:
        tbname - Name of the table
        oldColumn - Old name of the column
        newColumn - New name of the column
        Returns:
        SQL statement to populate the new column
        Throws:
        java.lang.Exception
      • columnHasDefault

        public boolean columnHasDefault(java.lang.String name)
        Identifies whether this class provides default logic for the specified column.
        Parameters:
        name - Column name
        Returns:
        True if default logic is provided, else False.