
/*------ ATD 324443 ------*/
DECLARE v_count NUMBER:=0;
BEGIN
	SELECT 1 INTO v_count FROM USER_TABLES WHERE UPPER(table_name) = 'SALDOICMSDIFAL' ;
	EXCEPTION
	WHEN NO_DATA_FOUND THEN
	BEGIN
		EXECUTE IMMEDIATE 'create table SALDOICMSDIFAL (
		ID INT NOT NULL,
		FILIAL VARCHAR2(2),
		UF VARCHAR2(2),
		MES VARCHAR2(2),
		ANO VARCHAR2(4),
		SALDODIFAL NUMBER(15,2),
		SALDOFCP NUMBER(15,2))';
		EXECUTE IMMEDIATE 'ALTER TABLE SALDOICMSDIFAL ADD CONSTRAINT PK_SALDOICMSDIFAL PRIMARY KEY (ID)';
		EXECUTE IMMEDIATE 'CREATE SEQUENCE SALDOICMSDIFAL_SEQ MINVALUE 1 MAXVALUE 
		999999999999999999999999999 INCREMENT BY 1 NOCYCLE NOORDER';
		EXECUTE IMMEDIATE 'CREATE OR REPLACE TRIGGER SALDOICMSDIFAL_I
		BEFORE INSERT ON SALDOICMSDIFAL for each ROW
		WHEN (new.ID IS NULL)
		BEGIN
		SELECT SALDOICMSDIFAL_SEQ.NEXTVAL INTO :new.ID FROM dual;
		END;';
	END;
END;
/