
/*------ ATD 341429 ------*/
-- Alteracao da estrutura da tabela ITNFENTCOMPLEMENTO (PA 332032)

DECLARE v_count NUMBER(1) := 0; 

BEGIN 

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITNFENTCOMPLEMENTO' AND Upper(column_name) = 'RE_BASEST'; 

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE ITNFENTCOMPLEMENTO ADD RE_BASEST NUMERIC(15,2) '; 

END IF;


SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITNFENTCOMPLEMENTO' AND Upper(column_name) = 'RE_VALORST'; 

IF v_count = 0 THEN 

EXECUTE IMMEDIATE 'ALTER TABLE ITNFENTCOMPLEMENTO ADD RE_VALORST NUMERIC(15,2) '; 

END IF;

-- CORRIGINDO SCRIPT ERRADO DO PA 332032

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITEMCLICOMPLEMENTO' AND Upper(column_name) = 'RE_BASEST'; 

IF v_count > 0 THEN 

EXECUTE IMMEDIATE 'ALTER TABLE ITEMCLICOMPLEMENTO DROP COLUMN RE_BASEST '; 

END IF;

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'ITEMCLICOMPLEMENTO' AND Upper(column_name) = 'RE_VALORST'; 

IF v_count > 0 THEN 

EXECUTE IMMEDIATE 'ALTER TABLE ITEMCLICOMPLEMENTO DROP COLUMN RE_VALORST '; 

END IF;

END;