com.ibm.tivoli.maximo.dbmanage.statement

Class InsertSql

  • java.lang.Object
    • com.ibm.tivoli.maximo.dbmanage.statement.InsertSql


  • public class InsertSql
    extends java.lang.Object
    Creates an insert statement, given list of column names and values for those columns.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  InsertSql.CurrentDateTime
      special replacement when creating insert
    • Constructor Summary

      Constructors 
      Constructor and Description
      InsertSql(java.lang.String table, java.sql.Connection connection)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addColumnStringValue(java.lang.String column, java.lang.String value)
      Add a string column value for the insert.
      void addColumnValue(java.lang.String column, java.lang.Object value)
      Add a column value for the insert.
      java.lang.Integer addedUniqueIdPosition() 
      void addHexColumnValue(java.lang.String column, java.lang.String value) 
      void changeTable(java.lang.String table)
      Change the target table of the insert.
      java.lang.String generateInsertSelectSql()
      Returns SQL in the form of: "insert into () select from " Add " where " to complete the select-for-insert statement.
      java.lang.String generateInsertSql()
      Produce the insert statement given the data given.
      java.lang.String getAddedUid() 
      java.lang.String getAddedUidSequence() 
      void setColumnValues(AttributeStorage sequenceDef)
      Set values from the AttributeStorage object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InsertSql

        public InsertSql(java.lang.String table,
                         java.sql.Connection connection)
                  throws java.sql.SQLException
        Constructor
        Parameters:
        table - Name of the table to insert into.
        serverType - Type of database server to create the insert for.
        Throws:
        MXException
        java.sql.SQLException
    • Method Detail

      • addColumnValue

        public void addColumnValue(java.lang.String column,
                                   java.lang.Object value)
        Add a column value for the insert. Calling this a second time for the same value will replace the earlier value. Null value will remove the column from the insert.
        Parameters:
        column - The name of the column.
        value - The value can be a String (which will be quoted), a Boolean (converted to 0 or 1), a CurrentDateTime (depends on server), or other (toString() will be used.)
      • addColumnStringValue

        public void addColumnStringValue(java.lang.String column,
                                         java.lang.String value)
        Add a string column value for the insert. The value will be quote correctly.
        Parameters:
        column - The name of the column.
        value - The value string, which will be formatted with quotes and internal double single quotes.
      • generateInsertSql

        public java.lang.String generateInsertSql()
                                           throws java.sql.SQLException
        Produce the insert statement given the data given.
        Returns:
        The insert sql.
        Throws:
        MXException
        MXException
        java.sql.SQLException
      • generateInsertSelectSql

        public java.lang.String generateInsertSelectSql()
                                                 throws java.sql.SQLException
        Returns SQL in the form of: "insert into () select from " Add " where " to complete the select-for-insert statement.
        Throws:
        MXException
        java.sql.SQLException
        • changeTable

          public void changeTable(java.lang.String table)
          Change the target table of the insert. Good when you need to insert into MaxObject & MaxObjectCFG.
          Parameters:
          table - Name of new table to generate an insert for.
        • setColumnValues

          public void setColumnValues(AttributeStorage sequenceDef)
          Set values from the AttributeStorage object. All not-null values will be set. Strings will be quoted.
          Parameters:
          sequenceDef -
        • addHexColumnValue

          public void addHexColumnValue(java.lang.String column,
                                        java.lang.String value)
        • addedUniqueIdPosition

          public java.lang.Integer addedUniqueIdPosition()
                                                  throws java.sql.SQLException
          Throws:
          java.sql.SQLException
        • getAddedUidSequence

          public java.lang.String getAddedUidSequence()
                                               throws java.sql.SQLException
          Throws:
          java.sql.SQLException
        • getAddedUid

          public java.lang.String getAddedUid()
                                       throws java.sql.SQLException
          Throws:
          java.sql.SQLException