
/*------ ATD 323616 ------*/
-- Adicionando coluna CM_PIS na tabela CLAFISCCAD
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'CLAFISCCAD' AND Upper(column_name) = 'CM_PIS'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE CLAFISCCAD ADD CM_PIS CHAR(2) '; 
END;

-- Adicionando coluna CM_COFINS na tabela CLAFISCCAD
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'CLAFISCCAD' AND Upper(column_name) = 'CM_COFINS'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE CLAFISCCAD ADD CM_COFINS CHAR(2) '; 
END;

-- Adicionando coluna CM_PIS na tabela ITNFSAICOMPLEMENTO
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITNFSAICOMPLEMENTO' AND Upper(column_name) = 'CM_PIS'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE ITNFSAICOMPLEMENTO ADD CM_PIS CHAR(2) '; 
END;

-- Adicionando coluna CM_COFINS na tabela ITNFSAICOMPLEMENTO
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITNFSAICOMPLEMENTO' AND Upper(column_name) = 'CM_COFINS'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE ITNFSAICOMPLEMENTO ADD CM_COFINS CHAR(2) '; 
END;

-- Adicionando coluna CM_PIS na tabela ITNFENTCOMPLEMENTO
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITNFENTCOMPLEMENTO' AND Upper(column_name) = 'CM_PIS'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE ITNFENTCOMPLEMENTO ADD CM_PIS CHAR(2) '; 
END;

-- Adicionando coluna CM_COFINS na tabela ITNFENTCOMPLEMENTO
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITNFENTCOMPLEMENTO' AND Upper(column_name) = 'CM_COFINS'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE ITNFENTCOMPLEMENTO ADD CM_COFINS CHAR(2) '; 
END;