/* Sequence */ declare object_exists exception; pragma exception_init (object_exists , -00955); begin execute immediate 'CREATE SEQUENCE CONFERENCIA_PENDENCIA_SEQ INCREMENT BY 1 MAXVALUE 9999999 MINVALUE 1 CACHE 20'; exception when object_exists then null; end; / /* Create */ declare object_exists exception; pragma exception_init (object_exists , -00955); begin execute immediate 'CREATE TABLE CONFERENCIA_PENDENCIA ( CONFERENCIAPENDENCIA_ID NUMBER(7) NOT NULL, DESCPENDENCIA VARCHAR2(50) NULL, ACTIVO NUMBER(1) NULL, FECMODIF DATE NULL, USUARIO_ID NUMBER(7) NULL, PRIMARY KEY (CONFERENCIAPENDENCIA_ID) )'; exception when object_exists then null; end; / /* Alter table */ declare column_exists exception; pragma exception_init (column_exists , -01430); begin execute immediate 'ALTER TABLE LOG_CONFERENCIA ADD CONFERENCIAPENDENCIA_ID NUMBER(7) NULL'; exception when column_exists then null; end; / declare dup_val_on_index exception; except_02275 exception; pragma exception_init (dup_val_on_index , -01430); pragma exception_init (except_02275 , -02275); begin execute immediate 'ALTER TABLE LOG_CONFERENCIA ADD CONSTRAINT FK_LOGCONFERENCIA_CONFPEN FOREIGN KEY (CONFERENCIAPENDENCIA_ID) REFERENCES CONFERENCIA_PENDENCIA (CONFERENCIAPENDENCIA_ID)'; exception when dup_val_on_index then null; when except_02275 then null; end; / /* Insert */ declare ja_existe exception; pragma exception_init (ja_existe , -00001); begin execute immediate 'INSERT INTO CONFERENCIA_PENDENCIA VALUES(CONFERENCIA_PENDENCIA_SEQ.NEXTVAL, ''MOVIMENTO SEM BILHETE FISICO'', 1, SYSDATE, 1)'; exception when ja_existe then null; end;