/** * 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> * @tname VARCHAR(32), * @pkbatchsize INT AS BEGIN BEGIN TRANSACTION UPDATE AUTO_PK_SUPPORT set NEXT_ID = * NEXT_ID + * @pkbatchsize WHERE TABLE_NAME = * @tname SELECT NEXT_ID from AUTO_PK_SUPPORT where NEXT_ID = * @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()); }