public void createAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception {
    // check if a table exists

    // create AUTO_PK_SUPPORT table
    if (!autoPkTableExists(node)) {
      runUpdate(node, pkTableCreateString());
    }

    // delete any existing pk entries
    runUpdate(node, pkDeleteString(dbEntities));

    // insert all needed entries
    for (DbEntity ent : dbEntities) {
      runUpdate(node, pkCreateString(ent.getName()));
    }
  }
 /** Drops table named "AUTO_PK_SUPPORT" if it exists in the database. */
 public void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception {
   if (autoPkTableExists(node)) {
     runUpdate(node, dropAutoPkString());
   }
 }
 /**
  * Generates database objects to provide automatic primary key support. Method will execute the
  * following SQL statements:
  *
  * <p>1. Executed only if a corresponding table does not exist in the database.
  *
  * <pre>
  *    CREATE TABLE AUTO_PK_SUPPORT (
  *       TABLE_NAME VARCHAR(32) NOT NULL,
  *       NEXT_ID DECIMAL(19,0) NOT NULL
  *    )
  * </pre>
  *
  * <p>2. Executed under any circumstances.
  *
  * <pre>
  * if exists (SELECT * FROM sysobjects WHERE name = 'auto_pk_for_table')
  * BEGIN
  *    DROP PROCEDURE auto_pk_for_table
  * END
  * </pre>
  *
  * <p>3. Executed under any circumstances. CREATE PROCEDURE auto_pk_for_table
  *
  * <pre>
  * &#064;tname VARCHAR(32),
  * &#064;pkbatchsize INT AS BEGIN BEGIN TRANSACTION UPDATE AUTO_PK_SUPPORT set NEXT_ID =
  *              NEXT_ID +
  * &#064;pkbatchsize WHERE TABLE_NAME =
  * &#064;tname SELECT NEXT_ID from AUTO_PK_SUPPORT where NEXT_ID =
  * &#064;tname COMMIT END
  * </pre>
  *
  * @param node node that provides access to a DataSource.
  */
 @Override
 public void createAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception {
   super.createAutoPk(node, dbEntities);
   super.runUpdate(node, safePkProcDrop());
   super.runUpdate(node, unsafePkProcCreate());
 }
 /**
  * Drops database objects related to automatic primary key support. Method will execute the
  * following SQL statements:
  *
  * <pre>
  * if exists (SELECT * FROM sysobjects WHERE name = 'AUTO_PK_SUPPORT')
  * BEGIN
  *    DROP TABLE AUTO_PK_SUPPORT
  * END
  *
  *
  * if exists (SELECT * FROM sysobjects WHERE name = 'auto_pk_for_table')
  * BEGIN
  *    DROP PROCEDURE auto_pk_for_table
  * END
  * </pre>
  *
  * @param node node that provides access to a DataSource.
  */
 @Override
 public void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception {
   super.runUpdate(node, safePkProcDrop());
   super.runUpdate(node, safePkTableDrop());
 }