
/*------ ATD 334237 ------*/
DECLARE v_count NUMBER:=0;

BEGIN

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'PAGAMENTOVENDA' and UPPER(column_name) = 'RITEMPREV';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE PAGAMENTOVENDA ADD rItemPrev NUMBER(34) NULL';

END IF;

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'PAGAMENTOVENDA' and UPPER(column_name) = 'ORIGEM';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE PAGAMENTOVENDA ADD Origem VARCHAR2(2) NULL';

END IF;

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'PAGAMENTOVENDA' and UPPER(column_name) = 'TIPOPARCELA';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE PAGAMENTOVENDA ADD TipoParcela VARCHAR2(1) NULL';

END IF;

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'ITNFSAICOMPLEMENTO' and UPPER(column_name) = 'PFCP';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE ITNFSAICOMPLEMENTO ADD pFCP DECIMAL(5,2) NULL';

END IF;

SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'ITNFSAICOMPLEMENTO' and UPPER(column_name) = 'VFCP';

IF v_count = 0 THEN

EXECUTE IMMEDIATE 'ALTER TABLE ITNFSAICOMPLEMENTO ADD vFCP DECIMAL(15,2) NULL';

END IF;

END;
/*------ ATD 335485 ------*/
DECLARE v_count NUMBER:=0;
BEGIN
SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'OPEVIPILIF' and UPPER(column_name) = 'INDICADORORIGEM';
IF v_count = 0 THEN
EXECUTE IMMEDIATE 'ALTER TABLE OPEVIPILIF ADD INDICADORORIGEM CHAR(1) NULL';
END IF;
END;


DECLARE v_count NUMBER:=0;
BEGIN
SELECT Count(1) INTO v_count FROM USER_TAB_COLUMNS WHERE UPPER(table_name) = 'OPEVIPILIF' and UPPER(column_name) = 'NUMERODOCUMENTO';
IF v_count = 0 THEN
EXECUTE IMMEDIATE 'ALTER TABLE OPEVIPILIF ADD NUMERODOCUMENTO VARCHAR2(20) NULL';
END IF;
END;