<?xml version="1.0" standalone="yes"?>
  <DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="VIE_KEY" fieldtype="string" required="true" WIDTH="128">
<PARAM Name="ORIGIN" Value="VIE_KEY" Roundtrip="True"/>
</FIELD>
<FIELD attrname="FONTE" fieldtype="bin.hex" SUBTYPE="Text">
<PARAM Name="PROVFLAGS" Value="1" Type="i4" Roundtrip="True"/>
<PARAM Name="ORIGIN" Value="FONTE" Roundtrip="True"/>
</FIELD>
</FIELDS>
<PARAMS DEFAULT_ORDER="1"/>
</METADATA>
<ROWDATA>
<ROW VIE_KEY="AGENCIABANC" FONTE="SELECT CODIGOAGENCIABANC&#010;,CODIGOBANCO&#010;,NUMEROAGENCIA NRAGENCIA&#010;,DIGITOAGENCIA DGAGENCIA&#010;,NOMEAGENCIA NOMEAGENCIA&#010;,cast(&apos;&apos; as varchar(60)) PESSOACONTATO&#010;,(CAST(DDDFONE AS VARCHAR(4)) || CAST(NUMEROFONE AS VARCHAR(9))) TELEFONE&#010;,CODIGOENDERECO&#010;,cast(NUMENDERAGENCIA as varchar(10)) NRENDERECO&#010;,COMPLENDERAGENCIA COMPLEMENTO&#010;FROM AGENCIA&#010;WHERE CODIGOAGENCIABANC &gt; -1&#010; "/>
<ROW VIE_KEY="CLIENTECOBRANCA" FONTE="select&#010;  PE.CODIGOPESSOAFIN CODIGOCLIENTE&#010;, TL.DSTIPOLOGRADORO LOGRADCOBRANCA&#010;, LO.NOMELOGRADORO ENDERECOCOBRANCA&#010;, PE.NRENDERECO NUMENDERCOBRANCA&#010;, PE.COMPLEMENTO COMPLENDERCOBRANCA&#010;, BA.NOMEBAIRRO BAIRROENDERCOBRANCA&#010;, MU.SIGLAESTADO SIGLAESTADO&#010;, MU.CODIGOMUNICIPIO CODIGOMUNIC&#010;, EN.CEP CEPENDERCOBRANCA&#010;FROM PESSOAENDERECO PE&#010;left join ENDERECO EN&#010;  on EN.CODIGOENDERECO = PE.CODIGOENDERECO&#010;left join TIPOLOGRADORO TL &#010;  on TL.CODIGOTIPOLOGRADORO = EN.CODIGOTIPOLOGRADORO &#010;left join LOGRADORO LO&#010;  on LO.CODIGOLOGRADORO = EN.CODIGOLOGRADORO&#010;left join BAIRRO BA &#010;  on BA.CODIGOBAIRRO = EN.CODIGOBAIRRO&#010;left join MUNICIPIO MU&#010;  on MU.CODIGOMUNICIPIO = EN.CODIGOMUNICIPIO&#010;where PE.SEQ = (SELECT MIN(AUX.SEQ) FROM PESSOAENDERECO AUX WHERE AUX.CODIGOPESSOAFIN=PE.CODIGOPESSOAFIN AND AUX.TIPOENDERECO=2)&#010; "/>
<ROW VIE_KEY="DEBITOFEDERALDARF" FONTE="Select CodigoEmpresa, CodigoEstab, ChaveDebitoFed, CodigoImposto, VariacaoImposto, DataVencimento, ValorDebito, SituacaoDebito, ObservDebito from DEBITOFEDERAL where FormaDebito &lt;&gt; 1&#010; "/>
<ROW VIE_KEY="ESOCIALDADOSFUNC" FONTE="SELECT CODIGOEMPRESA, CODIGOESOCIALTRANSACAO, CODIGOFUNCCONTR &#010;FROM ESOCIALDADOSS2200 S2200&#010;&#010;UNION &#010;&#010;SELECT CODIGOEMPRESA, CODIGOESOCIALTRANSACAO, CODIGOFUNCCONTR &#010;FROM ESOCIALDADOSS2300 S2300&#010; "/>
<ROW VIE_KEY="ESOCIALUNIFTAB14E15" FONTE="SELECT CODIGOSITUACAO,DESCRICAO,APLICACAO,DATAINICIAL,DATAFINAL FROM (SELECT T_T.CODIGOAGENTECAUSADOR CODIGOSITUACAO,CAST(T_T.DESCRICAOCAUSADORACIDTRAB AS VARCHAR(255)) AS DESCRICAO,CAST(NULL AS VARCHAR(1000)) APLICACAO,T_T.DATAINICIAL,T_T.DATAFINAL FROM AGENTECAUSADORACIDTRAB T_T UNION ALL SELECT T_T.CODIGOSITUACAO CODIGOSITUACAO,CAST(T_T.DESCRICAO AS VARCHAR(255)) DESCRICAO,T_T.APLICACAO AS APLICACAO,T_T.DATAINICIAL,T_T.DATAFINAL FROM CATSITGERADORA T_T) VW"/>
<ROW VIE_KEY="FPRACERTOCR" FONTE="select&#010;  CR.CODIGOESCRIT CODIGOESCRIT&#010;, CR.CODIGOACERTO CODIGOACERTO&#010;, CR.NUMERODCTOCR CODIGORECEBER&#010;, 2 OPERACAOACERTO&#010;FROM FPRACERTOCXFINCR CR&#010; "/>
<ROW VIE_KEY="FPRCONTARECEBER" FONTE="select&#010;  CR.CODIGOESCRIT CODIGOESCRIT&#010;, CR.CODIGOCLIENTE CODIGOPESSOAFIN&#010;, CR.NUMERODCTOCR CODIGORECEBERCAB&#010;, CR.NUMERODCTOCR CODIGORECEBER&#010;, CR.NUMERODCTOCR DOCUMENTOREC&#010;, CR.DATAVCTOCR DATAVENCIMENTOREC&#010;, CR.DATAHORALCTO DATALANCAMENTOREC&#010;, CR.CODIGOCAIXAPLANO CODIGOCONTA&#010;, CR.OBSERVCR HISTORICOREC&#010;, CR.ORIGEMDADO ORIGEMREC&#010;, CR.STATUSCR SITUACAOREC&#010;, CR.VALORCR NOMINALREC&#010;, 0 JUROREC&#010;, 0 MULTAREC&#010;, 0 DESCONTOREC&#010;, 0 TARIFAREC&#010;, CR.VALORCR VALORREC&#010;, CASE WHEN &#010;(CR.VALORCR - &#010;COALESCE((SELECT SUM(COALESCE(RB.VALORRCTOCR,0) + COALESCE(RB.DESCONTORCTOCR,0)) &#010;FROM CONTARECEBIDA RB &#010;WHERE RB.CODIGOESCRIT = CR.CODIGOESCRIT AND RB.NUMERODCTOCR = CR.NUMERODCTOCR),0) &#010;) &lt; 0 THEN 0 ELSE &#010;(CR.VALORCR - &#010;COALESCE((SELECT SUM(COALESCE(RB.VALORRCTOCR,0) + COALESCE(RB.DESCONTORCTOCR,0)) &#010;FROM CONTARECEBIDA RB &#010;WHERE RB.CODIGOESCRIT = CR.CODIGOESCRIT AND RB.NUMERODCTOCR = CR.NUMERODCTOCR),0) &#010;) END SALDOREC &#010;FROM CONTARECEBER CR&#010; "/>
<ROW VIE_KEY="FPRCONTARECEBERBAIXA" FONTE="select&#010;  CR.CODIGOESCRIT CODIGOESCRIT&#010;, CR.SEQCR CODIGORECBAIXA&#010;, CR.NUMERODCTOCR CODIGORECEBER&#010;, (SELECT AC.CODIGOACERTO&#010;   FROM FPRACERTOCXFINCR AC&#010;   WHERE AC.CODIGOESCRIT = CR.CODIGOESCRIT&#010;         AND AC.NUMERODCTOCR = CR.NUMERODCTOCR&#010;         AND AC.SEQCR = CR.SEQCR&#010;         AND rownum = 1) CODIGOACERTO&#010;, CR.VALORRCTOCR VALORBAIXA&#010;, CR.JURORCTOCR VALORJUROBAIXA&#010;, CR.MULTARCTOCR VALORMULTABAIXA&#010;, CR.DESCONTORCTOCR VALORDESCBAIXA&#010;FROM CONTARECEBIDA CR&#010; "/>
<ROW VIE_KEY="FPRCOTACAO" FONTE="select &#010;  CODIGOMOEDA&#010;, DATACOTACAO&#010;, VALORCOTACAO&#010;  from COTACAO&#010;where CODIGOMOEDA &gt; -1 WITH CHECK OPTION&#010; "/>
<ROW VIE_KEY="FPRMOEDA" FONTE="select&#010;  CODIGOMOEDA&#010;, NOMEMOEDA&#010;, TIPOCOTACAO&#010;, NUMERODECIMAL&#010;, NOMESINGULAR&#010;, NOMEPLURAL&#010;, CIFRAOMOEDA&#010;from MOEDA&#010;where CODIGOMOEDA &gt; -1 WITH CHECK OPTION&#010; "/>
<ROW VIE_KEY="FUNCIONARIO" FONTE="SELECT FC.CODIGOEMPRESA,&#010;       FC.CODIGOFUNCCONTR,&#010;       FP.CODIGOFUNCPESSOA,&#010;       FP.NOMEFUNC,&#010;       FP.APELIDOFUNC,&#010;       FP.FOTOFUNC,&#010;       TL.CODIGOTIPOLOGRAD,&#010;       TL.DESCRTIPOLOGRAD LOGRADFUNC,&#010;       FP.ENDERFUNC,&#010;       FP.COMPLENDER,&#010;       FP.NUMEROENDER,&#010;       FP.BAIRROFUNC,&#010;       FP.SIGLAESTADO,&#010;       FP.CODIGOMUNIC,&#010;       FP.CEPFUNC,&#010;       FP.DDDFONE,&#010;       FP.NUMEROFONE,&#010;       FP.RAMALFONE,&#010;       FP.ENDERELETR,&#010;       FP.DATANASC,&#010;       FP.SIGLAESTADONASC,&#010;       FP.CODIGOMUNICNASC,&#010;       FP.SEXO,&#010;       FP.RACACOR,&#010;       FP.DEFFISICA,&#010;       FP.DEFVISUAL,&#010;       FP.DEFAUDITIVA,&#010;       FP.DEFMENTAL,&#010;       FP.DEFINTELECTUAL,&#010;       FP.DEFREABILITADO,&#010;       FP.DEFOBS,&#010;       FP.ESTADOCIVIL,&#010;       FP.GRAUINSTR,&#010;       FP.NACIONALIDADE,&#010;       FP.DATACHEGADA,&#010;       FP.TIPOVISTO,&#010;       FP.CARTRNE,&#010;       FP.VALIDRNE,&#010;       FTD.UTILIZACARTEIRADIGITAL,&#010;       FTD.NUMEROCTPS,&#010;       FTD.SERIECTPS,&#010;       FTD.SIGLAESTADOCTPS,&#010;       FTD.EXPEDCTPS,&#010;       FP.PISFUNC,&#010;       FP.DATACADPIS,&#010;       FP.CPFFUNC,&#010;       FP.NUMERORG,&#010;       OERG.SIGLAORGAOEMISSOR ORGEMISRG,&#010;       FP.SIGLAESTADORG,&#010;       FP.EMISSRG,&#010;       FP.COMPLRG,&#010;       FP.TITELEIT,&#010;       FP.ZONATITELEIT,&#010;       FP.SECAOTITELEIT,&#010;       FP.CNHFUNC,&#010;       FP.CATEGCNH,&#010;       FP.VALIDCNH,&#010;       FP.CARTRESERV,&#010;       FP.CATEGCARTRESERV,&#010;       FP.CODIGOCONSELHO,&#010;       FP.NUMEROREGIST,&#010;       FP.DATAREGIST,&#010;       FP.PAISORIGEM,&#010;       FP.CERTCIVILTIPO,&#010;       FP.CERTCIVILEMISSAO,&#010;       FP.CERTCIVILTERMO,&#010;       FP.CERTCIVILLIVRO,&#010;       FP.CERTCIVILFOLHA,&#010;       FP.CERTCIVILCARTORIO,&#010;       FP.CERTCIVILSIGLAESTADO,&#010;       FP.CERTCIVILMUNIC,&#010;       FP.PASSAPNUMERO,&#010;       OEPASS.SIGLAORGAOEMISSOR PASSAPEMISSOR,&#010;       FP.PASSAPSIGLAESTADO,&#010;       FP.PASSAPEMISSAO,&#010;       FP.PASSAPVALIDADE,&#010;       FP.PASSAPPAISEMISSAO,&#010;       FP.PORTNATNUMERO,&#010;       FP.PORTNATDATA,&#010;       FP.RICNUMERO,&#010;       FP.RICSIGLAESTADO,&#010;       FP.RICMUNIC,&#010;       OERIC.SIGLAORGAOEMISSOR RICORGAOEMISSOR,&#010;       FP.RICDATAEXPED,&#010;       FP.BRPDHPPP,&#010;       FC.CODIGOTIPOCONTR,&#010;       FC.DATAADM,&#010;       FC.OPTANTEFGTS,&#010;       FC.DATAOPCAOFGTS,&#010;       FC.CONTAFGTS,&#010;       FC.CODIGOSIT,&#010;       FC.DATAAPOSENT,&#010;       FC.TIPOVINCULO,&#010;       FC.SIGLAESTADOMINREG,&#010;       FC.CODIGOCATEG,&#010;       FC.CATEGORIA,&#010;       FD.SINDICALIZADO,&#010;       FD.DESCMENSSIND,&#010;       FD.MESCONTRIBSIND,&#010;       FC.RECEBE13SAL,&#010;       FC.RECEBEADTO,&#010;       FC.PERCADTO,&#010;       FC.PERPGTO,&#010;       FC.MODOPGTO,&#010;       FC.TIPOCONTA,&#010;       FC.CODIGOBANCO,&#010;       FC.NUMEROAGENCIA,&#010;       FC.NUMEROCONTA,&#010;       FC.DIGITOCONTA,&#010;       FPIX.TIPOPIX,&#010;       FPIX.TIPOCHAVEPIX,&#010;       FPIX.CHAVEPIX,&#010;       FPIX.CHAVEPIXQRCODE,&#010;       VTH.CODIGOESCVT,&#010;       FC.NUMEROCARTAOVT,&#010;       FC.PREVTERMAFASTVT,&#010;       FVR.CODIGOESCALAREFEICAO,&#010;       FD.DESCCONTRIBSIND,&#010;       FC.EMITECARTAO,&#010;       FC.CHAPEIRA,&#010;       FC.NUMEROINSCRINSS,&#010;       FC.CODIGOIMPOSTO,&#010;       FC.VARIACAOIMPOSTO,&#010;       FC.CODIGOIMPOSTO13,&#010;       FC.VARIACAOIMPOSTO13,&#010;       FC.EMITIRCARNE,&#010;       FC.INSSFOLHA,&#010;       FC.DATADEM,&#010;       FC.DATAPGTORESCCOMPL,&#010;       FC.PARTICPAT,&#010;       FC.POSSUIALVARA,&#010;       FC.FORMACALCULO,&#010;       FC.DIACONTREXP,&#010;       FC.DIAPRORROGCONTREXP,&#010;       FD.DESCCUSTCONFED,&#010;       FD.DESCTAXAASSIST,&#010;       FC.DATATRANSFEMP,&#010;       FC.CODIGOUSUARIO,&#010;       FC.DATAHORALCTO,&#010;       FC.ORIGEMDADO,&#010;       FC.TIPOINSCRSEFIP,&#010;       FC.DOCUMENTOSCOMPLETOS,&#010;       FC.UTILIZAQCOLABORE,&#010;       FC.PERFILTAREFFA,&#010;       FD.DESCONTAREVSAL,&#010;       FC.CODIGOFUNCCONTRSUBST,&#010;       FC.CODIGOPROCESSOJUDADM,&#010;       FC.INDICATPRIMEMP,&#010;       FC.MOTIVOCONTRAT,&#010;       FC.REGIMEPREV,&#010;       FC.REGIMETRAB,&#010;       FP.CODIGOPOSTAL,&#010;       FP.DATANATURAL,&#010;       FP.DDDCELULAR,&#010;       FP.EXPEDICAOCNH,&#010;       FP.EXPEDICAORNE,&#010;       FP.NUMEROCELULAR,&#010;       OECNH.SIGLAORGAOEMISSOR ORGAOEMISSORCNH,&#010;       OERNE.SIGLAORGAOEMISSOR ORGAOEMISSORRNE,&#010;       FP.VALIDADEREGIST,&#010;       CODIGOSIND,&#010;       FP.CODIGOORGAOEMISSORRG,&#010;       FP.CODIGOORGAOEMISSORCNH,&#010;       FP.CODIGOORGAOEMISSORPASPORT,&#010;       FP.CODIGOORGAOEMISSORRIC,&#010;       FP.CODIGOORGAOEMISSORRNE,&#010;       FP.NOMEFUNC AS NOMEFUNCGRAVA,&#010;       FC.DATAADM AS DATACONTREXP1,&#010;       FC.DATAADM AS  DATACONTREXP2,&#010;       SAL.CODIGOTABSAL,&#010;       ES.CODIGOATIVFEDERAL,&#010;       FG.CODIGOFUNCAO,&#010;       FG.CODIGOCARGO,&#010;       FE.CODIGOESCALA,&#010;       FE.TIPOJORNADA,&#010;       FE.DESCRTIPOJORNADA,&#010;       FES.CODIGOESTABIL,&#010;       FQ.CODIGOQUALIF,&#010;       FL.CLASSIFORGAN,&#010;       FC.DATAADM AS DATAINPERAQUIS,&#010;       FCI.CODIGOCONVOCACAO,&#010;       FCI.DATACONVOCACAO,&#010;       FCI.HORACONVOCACAO,&#010;       FCI.DATAPAGAMENTO,&#010;       FCI.DATASITUACAO,&#010;       FCI.HORASITUACAO,&#010;       FCI.STATUS,&#010;       FCI.INDICATIVOLOCAL,&#010;       FCI.SITUACAO,&#010;       SAL.CODIGOESTRUTSAL,&#010;       SAL.CODIGOMOTIVO,&#010;       SAL.TIPOSALARIO,&#010;       SAL.VALORSAL,&#010;       SAL.COMPLSAL,&#010;       SAL.ANTECSAL,&#010;       SAL.SALCARNE,&#010;       SAL.DESCRSAL,&#010;       SAL.SEQ,&#010;       SAL.DATAEFEITO,&#010;       FD.MESTAXAASSISTENCIAL,&#010;       FD.DESCANOADMISSAO,&#010;       FAD.JAEXPOSTO,&#010;       FAD.AGENTENOCIVO,&#010;       FL.CODIGOESTAB,&#010;       FL.TIPOADMCAGED,&#010;       FS.CODIGOSEGURO,&#010;       FS.CODIGOSEGURO AS CODIGOSEGUROPROP,&#010;       FL.TIPOADM,&#010;       CTB.LOCALCTBRATEIO,&#010;       CTB.CODIGOLOCALCTB,&#010;       FL.DATAHORACADAST,&#010;       MAE.NOMEDEPEND AS MAE,&#010;       PAI.NOMEDEPEND AS PAI,&#010;       FAD.PERCINSALUB,&#010;       FAD.PERCPERICUL,&#010;       FE.TEMPOPARCIAL,&#010;       FL.FICHAREG,&#010;       FL.TIPOADMRAIS,&#010;       FL.INDICATADM,&#010;       FL.NUMEROPROCESSO,&#010;       FE.REGIMEJOR,&#010;       ES.CODIGOTIPOLOGRAD AS CODIGOTIPOLOGRADLOCAL,&#010;       FCI.LOGRADOURO,&#010;       FCI.NUMERO,&#010;       FCI.COMPLEMENTO,&#010;       FCI.BAIRRO,&#010;       FCI.CEP,&#010;       FCI.SIGLAESTADO AS SIGLAESTADOLOCAL,&#010;       FCI.CODIGOMUNIC AS CODIGOMUNICLOCAL,&#010;       FL.LIVROREG,&#010;       FL.FOLHALIVROREG,&#010;       FS.NUMEROAPOLICE,&#010;       FS.DATAVALIDADE,&#010;       FS.DATAVALIDADE AS DATAVALIDADEPROP,&#010;       FS.NUMEROAPOLICE AS NUMEROAPOLICEPROP,&#010;       FP.CASADOBR,&#010;       FP.FILHOSBR,&#010;       FC.INDNUMEROIDENTFISCAL,&#010;       FP.DEFCOTA,&#010;       FC.EMPCONTRATAPRENDIZ,&#010;       FC.CODIGOCURSOFORM,&#010;       FC.NATUREZAESTAGIO,&#010;       FC.NIVELESTAGIO,&#010;       FC.NUMEROIDENTFISCAL,&#010;       FC.ESOCIALSITUACAO,&#010;       FC.INSTITUICAOENSINO,&#010;       FC.AGENTEINTEGRACAO,&#010;       FC.CODIGOSUPERVISORESTAGIO,&#010;       FC.AREAATUACAO,&#010;       FC.CATEGESOCIAL,&#010;       FC.CODIGOTIPOFATO,&#010;       FC.ANTECIPDECIMOTERCEIROEFERIAS,&#010;       FC.TPINCLCONTR,&#010;       FC.JUSTCONTR,&#010;       FC.CLAUSULAASSEGRESC,&#010;       FP.UFCNH,&#010;       FC.RECEBSEGURODESEMPREGO,&#010;       FC.CNPJORIGEM,&#010;       FC.CNPJCEDNT,&#010;       FC.CATEGORIG,&#010;       FC.CATEGORIGCEDIDO,&#010;       FC.MATRICCED,&#010;       FC.DTADMCED,&#010;       FC.INFONUS,&#010;       FC.DATAADMORIG,&#010;       FC.MATRICORIG,&#010;       FC.CODIGOEMPRESASUBST,&#010;       FP.NUMEROCNS,&#010;       FP.PRIMHABCNH,&#010;       FP.NOMESOCIAL,&#010;       FC.CODIGOEMPCONTRATAAPRENDIZ,&#010;       FP.OBSERV,&#010;       ES.TIPOALTERACAOESOCIAL,&#010;       FC.JUSTPRORROG,&#010;       FC.CODIGOESOCIALTRANSACAO,&#010;       FC.ORDEMCALCULO,&#010;       FC.ENVIOUPRORROGESOCIAL,&#010;       FC.MATRICULAESOCIAL,&#010;       CAST(NULL AS DATE) AS DATASOLICITACAOASO,&#010;       FP.TMPRESID,&#010;       FC.TPINSCR,&#010;       CAST(0 AS INTEGER) AS CADASTRATREICAP&#010; FROM FUNCCONTRATO FC&#010; JOIN FUNCPESSOA FP ON FC.CODIGOFUNCPESSOA = FP.CODIGOFUNCPESSOA&#010; LEFT JOIN&#010;  (SELECT FD.CODIGOEMPRESA,&#010;          FD.CODIGOFUNCCONTR,&#010;          MAX(FD.DATAINICIAL) DATAINICIAL&#010;   FROM FUNCSINDICATO FD&#010;   GROUP BY FD.CODIGOEMPRESA,&#010;            FD.CODIGOFUNCCONTR) FSD ON FSD.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FSD.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCPIX FPIX ON&#010;    FPIX.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;    AND FPIX.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCSINDICATO FD ON FD.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FD.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; AND FD.DATAINICIAL = FSD.DATAINICIAL&#010; LEFT JOIN&#010;  (SELECT FTD.CODIGOEMPRESA,&#010;          FTD.CODIGOFUNCCONTR,&#010;          MAX(FTD.DATAINICIAL) DATAINICIAL&#010;   FROM FUNCCTPS FTD&#010;   GROUP BY FTD.CODIGOEMPRESA,&#010;            FTD.CODIGOFUNCCONTR) FCTD ON FCTD.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FCTD.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCCTPS FTD ON FTD.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FTD.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; AND FTD.DATAINICIAL = FCTD.DATAINICIAL&#010; LEFT JOIN&#010;  (SELECT FEVT.CODIGOEMPRESA,&#010;          FEVT.CODIGOFUNCCONTR,&#010;          MAX(FEVT.DATAINICIAL) DATAINICIAL&#010;   FROM FUNCESCALAVALETRANSP FEVT&#010;   GROUP BY FEVT.CODIGOEMPRESA,&#010;            FEVT.CODIGOFUNCCONTR) VTHM&#010; ON VTHM.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND VTHM.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCESCALAVALETRANSP VTH&#010;  ON VTH.CODIGOEMPRESA = VTHM.CODIGOEMPRESA&#010; AND VTH.CODIGOFUNCCONTR = VTHM.CODIGOFUNCCONTR&#010; AND VTH.DATAINICIAL = VTHM.DATAINICIAL&#010; LEFT JOIN&#010;  (SELECT FEV.CODIGOEMPRESA,&#010;          FEV.CODIGOFUNCCONTR,&#010;          MAX(FEV.DATAINICIAL) DATAINICIAL&#010;   FROM FUNCESCALAVALEREFEICAO FEV&#010;   GROUP BY FEV.CODIGOEMPRESA,&#010;            FEV.CODIGOFUNCCONTR) FEVM&#010; ON FEVM.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FEVM.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCESCALAVALEREFEICAO FVR&#010;  ON FVR.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FVR.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; AND FVR.DATAINICIAL = FEVM.DATAINICIAL&#010; LEFT JOIN TIPOLOGRADOURO TL ON FP.CODIGOTIPOLOGRAD = TL.CODIGOTIPOLOGRAD&#010; LEFT JOIN ORGAOEMISSOR OERG ON FP.CODIGOORGAOEMISSORRG = OERG.CODIGOORGAOEMISSOR&#010; LEFT JOIN ORGAOEMISSOR OECNH ON FP.CODIGOORGAOEMISSORCNH = OECNH.CODIGOORGAOEMISSOR&#010; LEFT JOIN ORGAOEMISSOR OEPASS ON FP.CODIGOORGAOEMISSORPASPORT = OEPASS.CODIGOORGAOEMISSOR&#010; LEFT JOIN ORGAOEMISSOR OERIC ON FP.CODIGOORGAOEMISSORRIC = OERIC.CODIGOORGAOEMISSOR&#010; LEFT JOIN ORGAOEMISSOR OERNE ON FP.CODIGOORGAOEMISSORRNE = OERNE.CODIGOORGAOEMISSOR&#010; LEFT JOIN&#010;  (SELECT M.CODIGOEMPRESA,&#010;          M.CODIGOFUNCCONTR,&#010;          MAX(M.DATAINICIAL) DATAINICIAL&#010;   FROM FUNCSALARIO M&#010;   GROUP BY M.CODIGOEMPRESA,&#010;            M.CODIGOFUNCCONTR) FSm&#010;  ON FSM.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND FSM.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCSALARIO SAL ON&#010;     SAL.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND SAL.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND SAL.DATAINICIAL = FSm.DATAINICIAL&#010;     AND EXISTS(SELECT MAX(FUB.SEQ)&#010;                FROM FUNCSALARIO FUB&#010;                WHERE FUB.DATAINICIAL   = SAL.DATAINICIAL&#010;                AND FUB.CODIGOEMPRESA = SAL.CODIGOEMPRESA&#010;                AND FUB.CODIGOFUNCCONTR = SAL.CODIGOFUNCCONTR&#010;                HAVING MAX(FUB.SEQ) = SAL.SEQ)&#010; LEFT JOIN FUNCLOCAL FL ON&#010;     FL.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FL.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND (EXISTS (SELECT MAX(FLS.DATATRANSF) FROM FUNCLOCAL FLS&#010;                  WHERE FLS.CODIGOEMPRESA = FL.CODIGOEMPRESA&#010;                    AND FLS.CODIGOFUNCCONTR = FL.CODIGOFUNCCONTR&#010;                    HAVING(MAX(FLS.DATATRANSF) = FL.DATATRANSF)))&#010; LEFT JOIN ESTAB ES ON&#010;     ES.CODIGOEMPRESA = FL.CODIGOEMPRESA&#010;     AND ES.CODIGOESTAB = FL.CODIGOESTAB&#010; LEFT JOIN FUNCCARGO FG ON&#010;     FG.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FG.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND(EXISTS (SELECT MAX(FGS.DATAINICIAL) FROM FUNCCARGO FGS&#010;                 WHERE FGS.CODIGOEMPRESA = FG.CODIGOEMPRESA&#010;                       AND FGS.CODIGOFUNCCONTR = FG.CODIGOFUNCCONTR&#010;                       HAVING (MAX(FGS.DATAINICIAL) = FG.DATAINICIAL)))&#010; LEFT JOIN FUNCESCALA FE ON&#010;     FE.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FE.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND (EXISTS (SELECT MAX(FES.DATAINICIAL) FROM FUNCESCALA FES&#010;                  WHERE FES.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;                  AND FES.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;                  HAVING (MAX(FES.DATAINICIAL) = FE.DATAINICIAL)))&#010; LEFT JOIN FUNCESTABIL FES ON&#010;     FES.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FES.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND (EXISTS (SELECT MAX(FESS.DATAINICIAL) FROM FUNCESTABIL FESS&#010;                  where FESS.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;                  AND FESS.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;                  HAVING MAX(FESS.DATAINICIAL) = FES.DATAINICIAL))&#010; LEFT JOIN FUNCQUALIF FQ ON&#010;     FQ.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FQ.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND (EXISTS (SELECT MAX(FQS.DATAINICIAL) FROM FUNCQUALIF FQS&#010;                  WHERE FQS.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;                  AND FQS.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;                  HAVING MAX(FQS.DATAINICIAL) = FQ.DATAINICIAL))&#010; LEFT JOIN FUNCCONTRINTERMITENTE FCI ON&#010;     FCI.CODIGOEMPRESA = fc.CODIGOEMPRESA&#010;     AND FCI.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND (EXISTS (SELECT MAX(FCIS.DATACONVOCACAO) FROM FUNCCONTRINTERMITENTE FCIS&#010;                  WHERE FCIS.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;                  AND FCIS.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;                  HAVING MAX(FCIS.DATACONVOCACAO) = FCI.DATACONVOCACAO))&#010; LEFT JOIN FUNCADICIONAL FAD ON&#010;     FAD.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FAD.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND (EXISTS (SELECT MAX(FADS.DATAINICIAL) FROM FUNCADICIONAL FADS&#010;                  WHERE FADS.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;                  AND FADS.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;                  HAVING MAX(FADS.DATAINICIAL) = FAD.DATAINICIAL))&#010; LEFT JOIN FUNCSEGURO FS ON&#010;     FS.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND FS.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND EXISTS (SELECT MAX(FSS.DATAINICIAL) FROM FUNCSEGURO FSS&#010;                 WHERE FSS.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;                 AND FSS.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;                 HAVING MAX(FSS.DATAINICIAL) = FS.DATAINICIAL)&#010; LEFT JOIN&#010;  (SELECT M.CODIGOEMPRESA,&#010;          M.CODIGOFUNCCONTR,&#010;          MAX(M.DATAOPCAO) DATAOPCAO&#010;   FROM FUNCLOCALCTB M&#010;   GROUP BY M.CODIGOEMPRESA,&#010;            M.CODIGOFUNCCONTR) CTBMAIOR&#010;  ON CTBMAIOR.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010; AND CTBMAIOR.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010; LEFT JOIN FUNCLOCALCTB CTB ON&#010;     CTB.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND CTB.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND CTB.DATAOPCAO = CTBMAIOR.DATAOPCAO&#010; LEFT JOIN DEPENDENTE PAI ON&#010;     PAI.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND PAI.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND PAI.PARENTESCO = &apos;03&apos;&#010;     AND PAI.SEXO = 1&#010; LEFT JOIN DEPENDENTE MAE ON&#010;     MAE.CODIGOEMPRESA = FC.CODIGOEMPRESA&#010;     AND MAE.CODIGOFUNCCONTR = FC.CODIGOFUNCCONTR&#010;     AND MAE.PARENTESCO = &apos;03&apos;&#010;     AND MAE.SEXO = 2"/>
<ROW VIE_KEY="FUNCIONARIORETIFICACAO" FONTE="select FC.CODIGOEMPRESA,&#010;       FC.CODIGOFUNCCONTR,&#010;       FC.CODIGOFUNCPESSOA,&#010;       FC.DATAADM,&#010;       FP.NOMEFUNC,&#010;       FP.CPFFUNC,&#010;       FP.DATANASC,&#010;       FP.PISFUNC,&#010;       FP.DATACADPIS,&#010;       FP.NOMESOCIAL,&#010;       FP.APELIDOFUNC,&#010;       FP.FOTOFUNC,&#010;       FC.DATADEM&#010;from FUNCCONTRATO FC&#010;join FUNCPESSOA FP on FP.CODIGOFUNCPESSOA = FC.CODIGOFUNCPESSOA&#010; "/>
<ROW VIE_KEY="LOTERESCISAO" FONTE="select A.CODIGOEMPRESA, AF.CODIGOFUNCCONTR, A.loteavprevresccolet AS LOTE, A.DATACADASTRO, A.ORIGEM, A.ESTADO AS TIPORESCISAO, A.DATARESC, A.DATAPGTORESC from avisoprevresccolet A JOIN avisoprevresccoletfunc AF ON A.codigoempresa = AF.codigoempresa AND A.loteavprevresccolet = AF.loteavprevresccolet&#010; "/>
<ROW VIE_KEY="PATBEMDOCUMENTOFISCALCOMP" FONTE="select PBD.CODIGOBEM,&#010;       DOC.CODIGODOCUMENTOFISCAL,&#010;       DOC.CODIGOPESSOA,&#010;       DOC.NUMERONF,&#010;       DOC.ESPECIENF,&#010;       DOC.SERIENF,&#010;       DOC.SUBSERIENF,&#010;       DOC.DATALCTO,&#010;       DOC.VALORCONTABIL,&#010;       DOC.EMITENTENF,&#010;       DOC.CDMODELO,&#010;       DOC.CHAVENFE,&#010;       PBD.TIPODOCUMENTO&#010;from LCTODOCUMENTOFISCAL DOC&#010;join PATBEMDOCUMENTOFISCAL PBD&#010;  on PBD.CODIGODOCUMENTOFISCAL = DOC.CODIGODOCUMENTOFISCAL&#010;ORDER BY PBD.CODIGOBEM, CODIGODOCUMENTOFISCAL"/>
<ROW VIE_KEY="PLANOESPECIMOB" FONTE="select CODIGOEMPRESA, CONTACTB from PLANOESPEC where CONTAIMOB = 1 ORDER BY CODIGOEMPRESA, CONTACTB&#010; "/>
<ROW VIE_KEY="VENDERECO" FONTE="SELECT T1.CODIGOENDERECO,&#010;       T5.CODIGOMUNICIPIO,&#010;       T2.DSTIPOLOGRADORO||&apos; &apos;||T3.NOMELOGRADORO ENDERECO1,&#010;       T4.NOMEBAIRRO||&apos; - &apos;||T5.NOMEMUNIC||&apos; - &apos;||T5.SIGLAESTADO ENDERECO2,&#010;       T1.CEP,&#010;       T1.COMPLEMENTO,&#010;       T2.DSTIPOLOGRADORO,&#010;       T3.NOMELOGRADORO,&#010;       T1.CODIGOBAIRRO,&#010;       T4.NOMEBAIRRO,&#010;       T5.NOMEMUNIC,&#010;       T5.SIGLAESTADO&#010;FROM ENDERECO T1 &#010;JOIN TIPOLOGRADORO T2 ON (T2.CODIGOTIPOLOGRADORO = T1.CODIGOTIPOLOGRADORO)&#010;JOIN LOGRADORO T3 ON (T3.CODIGOLOGRADORO = T1.CODIGOLOGRADORO)&#010;JOIN BAIRRO T4 ON (T4.CODIGOBAIRRO = T1.CODIGOBAIRRO) &#010;JOIN MUNICIPIO T5 ON (T5.CODIGOMUNICIPIO = T1.CODIGOMUNICIPIO)&#010;ORDER BY T1.CODIGOENDERECO&#010; "/>
<ROW VIE_KEY="VESTABHISTORICO" FONTE="SELECT&#010;E.CODIGOEMPRESA,&#010;E.CODIGOESTAB,&#010;E.NOMEESTAB,&#010;CASE WHEN EH.NOMEESTABCOMPLETO IS NULL THEN E.NOMEESTABCOMPLETO ELSE EH.NOMEESTABCOMPLETO END NOMEESTABCOMPLETO,&#010;CASE WHEN EH.NOMEFANTASIA IS NULL THEN E.NOMEFANTASIA ELSE EH.NOMEFANTASIA END NOMEFANTASIA,&#010;E.APELIDOESTAB,&#010;CASE WHEN EH.CODIGOTIPOLOGRAD IS NULL THEN E.CODIGOTIPOLOGRAD ELSE EH.CODIGOTIPOLOGRAD END CODIGOTIPOLOGRAD,&#010;CASE WHEN EH.CODIGOTIPOLOGRAD IS NULL THEN TLE.DESCRTIPOLOGRAD ELSE TLEH.DESCRTIPOLOGRAD END DESCRTIPOLOGRAD,&#010;CASE WHEN EH.ENDERECOESTAB IS NULL THEN E.ENDERECOESTAB ELSE EH.ENDERECOESTAB END ENDERECOESTAB,&#010;CASE WHEN EH.NUMENDERESTAB IS NULL THEN E.NUMENDERESTAB ELSE EH.NUMENDERESTAB END NUMENDERESTAB,&#010;CASE WHEN EH.COMPLENDERESTAB IS NULL THEN E.COMPLENDERESTAB ELSE EH.COMPLENDERESTAB END COMPLENDERESTAB,&#010;CASE WHEN EH.BAIRROENDERESTAB IS NULL THEN E.BAIRROENDERESTAB ELSE EH.BAIRROENDERESTAB END BAIRROENDERESTAB,&#010;E.DATAALTERENDER,&#010;CASE WHEN EH.SIGLAESTADO IS NULL THEN E.SIGLAESTADO ELSE EH.SIGLAESTADO END SIGLAESTADO,&#010;CASE WHEN EH.CODIGOMUNIC IS NULL THEN E.CODIGOMUNIC ELSE EH.CODIGOMUNIC END CODIGOMUNIC,&#010;CASE WHEN EH.CEPENDERESTAB IS NULL THEN E.CEPENDERESTAB ELSE EH.CEPENDERESTAB END CEPENDERESTAB,&#010;E.DDDFONE,&#010;E.NUMEROFONE,&#010;E.DDDFAX,&#010;E.NUMEROFAX,&#010;E.CAIXAPOSTAL,&#010;E.SIGLAESTADOCXP,&#010;E.CEPCAIXAPOSTAL,&#010;E.EMAIL,&#010;E.PAGINAINTERNET,&#010;E.DATAINICIOATIV,&#010;E.DATAENCERATIV,&#010;E.SOCIEDADECONTAPARTICIPACAO,&#010;E.INSCRICAOSCP,&#010;CASE WHEN EH.TIPOINSCR IS NULL THEN E.TIPOINSCR ELSE EH.TIPOINSCR END TIPOINSCR,&#010;CASE WHEN EH.INSCRFEDERAL IS NULL THEN E.INSCRFEDERAL ELSE EH.INSCRFEDERAL END INSCRFEDERAL,&#010;E.SUFRAMA,&#010;E.CODIGONATURJURID,&#010;CASE WHEN EH.CODIGOATIVFEDERAL IS NULL THEN E.CODIGOATIVFEDERAL ELSE EH.CODIGOATIVFEDERAL END CODIGOATIVFEDERAL,&#010;CASE WHEN EH.DESCRATIVFEDESTAB IS NULL THEN E.DESCRATIVFEDESTAB ELSE EH.DESCRATIVFEDESTAB END DESCRATIVFEDESTAB,&#010;E.DATAALTERATIVFED,&#010;E.TIPOREGIST,&#010;CASE WHEN EH.NUMEROREGIST IS NULL THEN E.NUMEROREGIST ELSE EH.NUMEROREGIST END NUMEROREGIST,&#010;E.DATAREGIST,&#010;E.OBSERVREGIST,&#010;CASE WHEN EH.INSCRESTAD IS NULL THEN E.INSCRESTAD ELSE EH.INSCRESTAD END INSCRESTAD,&#010;CASE WHEN EH.CODIGOATIVESTAD IS NULL THEN E.CODIGOATIVESTAD ELSE EH.CODIGOATIVESTAD END CODIGOATIVESTAD,&#010;CASE WHEN EH.DESCRATIVESTESTAB IS NULL THEN E.DESCRATIVESTESTAB ELSE EH.DESCRATIVESTESTAB END DESCRATIVESTESTAB,&#010;E.INSCRMUNIC,&#010;CASE WHEN EH.CODIGOATIVMUNIC IS NULL THEN E.CODIGOATIVMUNIC ELSE EH.CODIGOATIVMUNIC END CODIGOATIVMUNIC,&#010;E.INSCRIMOBILIARIA,&#010;E.ESPECIEESTAB,&#010;E.INSCRBANCOCENTRAL,&#010;E.INSCRSUSEP,&#010;CASE WHEN EH.DESCRATIVMUNESTAB IS NULL THEN E.DESCRATIVMUNESTAB ELSE EH.DESCRATIVMUNESTAB END DESCRATIVMUNESTAB,&#010;E.PORTEEMPRESA,&#010;E.INSCRCVM,&#010;E.CODIGOTABFERIADO,&#010;E.VALORNOMINALCOTAS,&#010;E.CAEPF,&#010;E.NOMEAUDITOR,&#010;E.CVMAUDITOR,&#010;E.CAPITALSOCIAL,&#010;EH.DATAHISTORICO&#010;FROM ESTAB E &#010;JOIN ESTABHISTORICO EH&#010;ON EH.CODIGOEMPRESA = E.CODIGOEMPRESA &#010;AND EH.CODIGOESTAB = E.CODIGOESTAB&#010;LEFT JOIN TIPOLOGRADOURO TLE&#010;ON TLE.CODIGOTIPOLOGRAD = E.CODIGOTIPOLOGRAD&#010;LEFT JOIN TIPOLOGRADOURO TLEH&#010;ON TLEH.CODIGOTIPOLOGRAD = EH.CODIGOTIPOLOGRAD&#010; "/>
<ROW VIE_KEY="VESTABHISTORICOATUAL" FONTE="SELECT&#010;E.CODIGOEMPRESA,&#010;E.CODIGOESTAB,&#010;E.NOMEESTAB,&#010;CASE WHEN EH.NOMEESTABCOMPLETO IS NULL THEN E.NOMEESTABCOMPLETO ELSE EH.NOMEESTABCOMPLETO END NOMEESTABCOMPLETO,&#010;CASE WHEN EH.NOMEFANTASIA IS NULL THEN E.NOMEFANTASIA ELSE EH.NOMEFANTASIA END NOMEFANTASIA,&#010;E.APELIDOESTAB,&#010;CASE WHEN EH.CODIGOTIPOLOGRAD IS NULL THEN E.CODIGOTIPOLOGRAD ELSE EH.CODIGOTIPOLOGRAD END CODIGOTIPOLOGRAD,&#010;CASE WHEN EH.CODIGOTIPOLOGRAD IS NULL THEN TLE.DESCRTIPOLOGRAD ELSE TLEH.DESCRTIPOLOGRAD END DESCRTIPOLOGRAD,&#010;CASE WHEN EH.ENDERECOESTAB IS NULL THEN E.ENDERECOESTAB ELSE EH.ENDERECOESTAB END ENDERECOESTAB,&#010;CASE WHEN EH.NUMENDERESTAB IS NULL THEN E.NUMENDERESTAB ELSE EH.NUMENDERESTAB END NUMENDERESTAB,&#010;CASE WHEN EH.COMPLENDERESTAB IS NULL THEN E.COMPLENDERESTAB ELSE EH.COMPLENDERESTAB END COMPLENDERESTAB,&#010;CASE WHEN EH.BAIRROENDERESTAB IS NULL THEN E.BAIRROENDERESTAB ELSE EH.BAIRROENDERESTAB END BAIRROENDERESTAB,&#010;E.DATAALTERENDER,&#010;CASE WHEN EH.SIGLAESTADO IS NULL THEN E.SIGLAESTADO ELSE EH.SIGLAESTADO END SIGLAESTADO,&#010;CASE WHEN EH.CODIGOMUNIC IS NULL THEN E.CODIGOMUNIC ELSE EH.CODIGOMUNIC END CODIGOMUNIC,&#010;CASE WHEN EH.CEPENDERESTAB IS NULL THEN E.CEPENDERESTAB ELSE EH.CEPENDERESTAB END CEPENDERESTAB,&#010;E.DDDFONE,&#010;E.NUMEROFONE,&#010;E.DDDFAX,&#010;E.NUMEROFAX,&#010;E.CAIXAPOSTAL,&#010;E.SIGLAESTADOCXP,&#010;E.CEPCAIXAPOSTAL,&#010;E.EMAIL,&#010;E.PAGINAINTERNET,&#010;E.DATAINICIOATIV,&#010;E.DATAENCERATIV,&#010;E.SOCIEDADECONTAPARTICIPACAO,&#010;E.INSCRICAOSCP,&#010;CASE WHEN EH.TIPOINSCR IS NULL THEN E.TIPOINSCR ELSE EH.TIPOINSCR END TIPOINSCR,&#010;CASE WHEN EH.INSCRFEDERAL IS NULL THEN E.INSCRFEDERAL ELSE EH.INSCRFEDERAL END INSCRFEDERAL,&#010;E.SUFRAMA,&#010;E.CODIGONATURJURID,&#010;CASE WHEN EH.CODIGOATIVFEDERAL IS NULL THEN E.CODIGOATIVFEDERAL ELSE EH.CODIGOATIVFEDERAL END CODIGOATIVFEDERAL,&#010;CASE WHEN EH.DESCRATIVFEDESTAB IS NULL THEN E.DESCRATIVFEDESTAB ELSE EH.DESCRATIVFEDESTAB END DESCRATIVFEDESTAB,&#010;E.DATAALTERATIVFED,&#010;E.TIPOREGIST,&#010;CASE WHEN EH.NUMEROREGIST IS NULL THEN E.NUMEROREGIST ELSE EH.NUMEROREGIST END NUMEROREGIST,&#010;E.DATAREGIST,&#010;E.OBSERVREGIST,&#010;CASE WHEN EH.INSCRESTAD IS NULL THEN E.INSCRESTAD ELSE EH.INSCRESTAD END INSCRESTAD,&#010;CASE WHEN EH.CODIGOATIVESTAD IS NULL THEN E.CODIGOATIVESTAD ELSE EH.CODIGOATIVESTAD END CODIGOATIVESTAD,&#010;CASE WHEN EH.DESCRATIVESTESTAB IS NULL THEN E.DESCRATIVESTESTAB ELSE EH.DESCRATIVESTESTAB END DESCRATIVESTESTAB,&#010;E.INSCRMUNIC,&#010;CASE WHEN EH.CODIGOATIVMUNIC IS NULL THEN E.CODIGOATIVMUNIC ELSE EH.CODIGOATIVMUNIC END CODIGOATIVMUNIC,&#010;E.INSCRIMOBILIARIA,&#010;E.ESPECIEESTAB,&#010;E.INSCRBANCOCENTRAL,&#010;E.INSCRSUSEP,&#010;CASE WHEN EH.DESCRATIVMUNESTAB IS NULL THEN E.DESCRATIVMUNESTAB ELSE EH.DESCRATIVMUNESTAB END DESCRATIVMUNESTAB,&#010;E.PORTEEMPRESA,&#010;E.INSCRCVM,&#010;E.CODIGOTABFERIADO,&#010;E.VALORNOMINALCOTAS,&#010;E.CAEPF,&#010;E.NOMEAUDITOR,&#010;E.CVMAUDITOR,&#010;E.CAPITALSOCIAL,&#010;EH.DATAHISTORICO&#010;FROM ESTAB E&#010;JOIN ESTABHISTORICO EH&#010;  ON EH.CODIGOEMPRESA = E.CODIGOEMPRESA&#010; AND EH.CODIGOESTAB = E.CODIGOESTAB&#010;LEFT JOIN TIPOLOGRADOURO TLE&#010;ON TLE.CODIGOTIPOLOGRAD = E.CODIGOTIPOLOGRAD&#010;LEFT JOIN TIPOLOGRADOURO TLEH&#010;ON TLEH.CODIGOTIPOLOGRAD = EH.CODIGOTIPOLOGRAD&#010;where EH.datahistorico = (Select MAX(EH2.DATAHISTORICO)&#010;                                                 FROM ESTABHISTORICO EH2&#010;                                                WHERE EH2.codigoempresa = EH.codigoempresa&#010;                                                  and EH2.codigoestab = EH.codigoestab&#010;                                                  and EH2.DATAHISTORICO &lt;= current_date)&#010; "/>
<ROW VIE_KEY="VWFUNCPLANOSAUDEDESPESADET" FONTE="SELECT t_t.CODIGOEMPRESA, &#010;t_t.CODIGOOUTEMP, &#010;t_t.CODIGOFUNCCONTR, &#010;t_t.COMPET, &#010;t_t.SEQ, &#010;NULL AS CODIGODEPEND, &#010;&apos;T&apos; AS TIPO, &#010;FP.NOMEFUNC AS NOMEDEPEND, &#010;FPS.DATAINICIAL, &#010;FPS.DATAFINAL, &#010;FPS.VALOR, &#010;FPS.VALORBENFEMP &#010;FROM FUNCPLANOSAUDEDESPESA t_t &#010;JOIN FUNCPLANOSAUDE FPS &#010;on t_t.CODIGOEMPRESA = FPS.CODIGOEMPRESA &#010;and t_t.CODIGOFUNCCONTR = FPS.CODIGOFUNCCONTR &#010;and t_t.CODIGOOUTEMP = FPS.CODIGOOUTEMP &#010;and t_t.DATAINICIAL = FPS.DATAINICIAL &#010;JOIN FUNCCONTRATO FC ON FC.CODIGOEMPRESA = FPS.CODIGOEMPRESA &#010;AND FC.CODIGOFUNCCONTR = FPS.CODIGOFUNCCONTR &#010;JOIN FUNCPESSOA FP ON FP.CODIGOFUNCPESSOA = FC.CODIGOFUNCPESSOA &#010;JOIN OUTRAEMPRESA OE ON OE.CODIGOOUTEMP = FPS.CODIGOOUTEMP &#010;WHERE FPS.DATAINICIAL = &#010;(SELECT MAX(PS1.DATAINICIAL) &#010;FROM FUNCPLANOSAUDE PS1 &#010;WHERE PS1.CODIGOEMPRESA = FPS.CODIGOEMPRESA &#010;AND PS1.CODIGOFUNCCONTR = FPS.CODIGOFUNCCONTR &#010;AND PS1.CODIGOOUTEMP = FPS.CODIGOOUTEMP &#010;and PS1.DATAINICIAL &lt;= LAST_DAY(t_t.COMPET))&#010;UNION ALL &#010;SELECT t_t.CODIGOEMPRESA, &#010;t_t.CODIGOOUTEMP, &#010;t_t.CODIGOFUNCCONTR, &#010;t_t.COMPET, &#010;t_t.SEQ, &#010;PSD.CODIGODEPEND, &#010;&apos;D&apos; AS TIPO, &#010;D.NOMEDEPEND, &#010;PS.DATAINICIAL, &#010;PS.DATAFINAL, &#010;PSD.VALOR, &#010;PSD.VALORBENFEMP &#010;FROM FUNCPLANOSAUDEDESPESA t_t &#010;JOIN FUNCPLANOSAUDE PS &#010;on t_t.CODIGOEMPRESA = PS.CODIGOEMPRESA &#010;and t_t.CODIGOFUNCCONTR = PS.CODIGOFUNCCONTR &#010;and t_t.CODIGOOUTEMP = PS.CODIGOOUTEMP &#010;and t_t.DATAINICIAL = PS.DATAINICIAL &#010;JOIN FUNCPLANOSAUDEDEPEND PSD ON PS.CODIGOEMPRESA = PSD.CODIGOEMPRESA &#010;AND PS.CODIGOFUNCCONTR = PSD.CODIGOFUNCCONTR &#010;AND PS.CODIGOOUTEMP = PSD.CODIGOOUTEMP &#010;AND PS.DATAINICIAL = PSD.DATAINICIAL &#010;JOIN FUNCCONTRATO FP ON FP.CODIGOEMPRESA = PS.CODIGOEMPRESA &#010;AND FP.CODIGOFUNCCONTR = PS.CODIGOFUNCCONTR &#010;JOIN OUTRAEMPRESA OE ON OE.CODIGOOUTEMP = PS.CODIGOOUTEMP &#010;JOIN DEPENDENTE D ON D.CODIGOEMPRESA = PS.CODIGOEMPRESA &#010;AND D.CODIGOFUNCCONTR = PS.CODIGOFUNCCONTR &#010;AND D.CODIGODEPEND = PSD.CODIGODEPEND &#010;WHERE PS.DATAINICIAL = &#010;(SELECT MAX(PS1.DATAINICIAL) &#010;FROM FUNCPLANOSAUDE PS1 &#010;WHERE PS1.CODIGOEMPRESA = PS.CODIGOEMPRESA &#010;AND PS1.CODIGOFUNCCONTR = PS.CODIGOFUNCCONTR &#010;AND PS1.CODIGOOUTEMP = PS.CODIGOOUTEMP &#010;AND PS1.DATAINICIAL &lt;= LAST_DAY(t_t.COMPET))"/>
<ROW VIE_KEY="VWGRUPOEMPRESA" FONTE="SELECT T_T.CODIGOGRUPOPROC,T_T.CODIGOEMPRESAPROC,T_T.CODIGOEMPRESAPROC AS CODIGOEMPRESA FROM GRUPOEMPRESA T_T"/>
</ROWDATA>
</DATAPACKET>
