ALTER TABLE TOTAISESTOQUE ADD COR VARCHAR(10);
COMMIT;

CREATE GENERATOR PQ_TOTESTOQUE;
COMMIT;

ALTER TABLE TOTAISESTOQUE ADD ID INTEGER;
commit;

update TOTAISESTOQUE set ID =(gen_id(PQ_TOTESTOQUE,1));
commit;

UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = 1 WHERE (RDB$FIELD_NAME = 'ID') AND (RDB$RELATION_NAME = 'TOTAISESTOQUE');
commit;

ALTER TABLE TOTAISESTOQUE ADD PRIMARY KEY (ID);
commit;

CREATE OR ALTER TRIGGER INSTOTESTOQUE FOR TOTAISESTOQUE
ACTIVE BEFORE INSERT POSITION 0
as 
begin 
   new.ID=gen_id(PQ_TOTESTOQUE,1);
end;
COMMIT;


