
/*------ ATD 344006 ------*/
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'OBSERVACAOFISCALNOTA' AND Upper(column_name) = 'TIPO'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE OBSERVACAOFISCALNOTA ADD TIPO CHAR (1) '; 
EXECUTE IMMEDIATE 'UPDATE OBSERVACAOFISCALNOTA SET TIPO = 'E' WHERE TIPO IS NULL AND NUMORD IN (SELECT NUMORD FROM NFENTRACAD)  ';
EXECUTE IMMEDIATE 'UPDATE OBSERVACAOFISCALNOTA SET TIPO = 'S' WHERE TIPO IS NULL AND NUMORD IN (SELECT NUMORD FROM NFSAIDACAD) ';
END;
/
DECLARE v_count NUMBER(1) := 0; 
BEGIN 
SELECT 1 INTO v_count FROM USER_TAB_COLUMNS WHERE Upper(table_name) = 'AJUSTEFISCALITEM' AND Upper(column_name) = 'TIPO'; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXECUTE IMMEDIATE 'ALTER TABLE AJUSTEFISCALITEM ADD TIPO CHAR (1) '; 
EXECUTE IMMEDIATE 'UPDATE AJUSTEFISCALITEM SET TIPO = 'E' WHERE TIPO IS NULL AND NUMORD IN (SELECT NUMORD FROM NFENTRACAD)  ';
EXECUTE IMMEDIATE 'UPDATE AJUSTEFISCALITEM SET TIPO = 'S' WHERE TIPO IS NULL AND NUMORD IN (SELECT NUMORD FROM NFSAIDACAD) ';
END;
/