Icon View Incident Report

Serious Serious
Reported By: Jeff Dunlop
Reported On: 3/1/2011
For: Version 2.05 Build 3
# 3390 Altering INTEGER Columns to IDENTITY Columns Can Cause Incorrect Last Identity Seed Value in Table

I want to create a DocketNo column, start it with SaleCode values, and then start incrementing from there. After I run this script, new records start with DocketNo 1, 2, etc. In the schema, the generation says it’s By Default, Seed 452437. After I repair the table, then it works properly.

SCRIPT ()
BEGIN
   DECLARE SaleCodeCursor CURSOR FOR Stmt;
   DECLARE SaleCode INT;
 
   PREPARE Stmt FROM 'SELECT MAX(SaleCode) + 1 AS NextSaleCode FROM Sale';
   OPEN SaleCodeCursor;
   FETCH FIRST FROM SaleCodeCursor INTO SaleCode;
 
   UNPREPARE Stmt;
 
   EXECUTE IMMEDIATE 'ALTER TABLE "Sale" DROP COLUMN "DocketNo"';
   EXECUTE IMMEDIATE 'ALTER TABLE "Sale"
                      ADD COLUMN "DocketNo" INTEGER GENERATED ALWAYS AS SaleCode NOT NULL';

   EXECUTE IMMEDIATE 'ALTER TABLE "Sale"
                      ALTER COLUMN "DocketNo" AS INTEGER 
                         GENERATED BY DEFAULT AS IDENTITY (START WITH ' + CAST(SaleCode AS VARCHAR) + ', INCREMENT BY 1) NOT NULL';
END



Resolution Resolution
Fixed Problem on 3/2/2011 in version 2.05 build 4


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB PHP Standard
ElevateDB PHP Standard with Source
ElevateDB PHP Trial
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image