Variáveis Integração Identificador de Regras

Os exemplos de regras abaixo são utilizados pelo identificador de regra IMP-660INTEG01, que são distribuídos para cada variável onde é permitido alterar o SQL padrão do sistema.
Os SQL's utilizados nos exemplos são exatamente os disponíveis na rotina de integração, devendo a regra respeitar o nome dos campos de retorno de cada variável."

Variável Comando SQL Padrão
VNotEnt

SELECT E440NFC.NUMNFC, E440NFC.CODFOR, E440NFC.CODSNF,

E440NFC.TNSPRO, E440NFC.NOPPRO, E440NFC.TNSSER,

E440NFC.NOPSER, E440NFC.DATEMI, E440NFC.DATENT,

E440NFC.VLRLIQ, E440NFC.VLRBIC, E440NFC.VLRICM,

E440NFC.VLRBIP, E440NFC.VLRIPI, E440NFC.VLRBSI,

E440NFC.VLRSIC, E440NFC.VLRBIS, E440NFC.VLRISS,

E440NFC.VLRBIR, E440NFC.VLRIRF, E440NFC.VLRLOU,

E440NFC.SITNFC, E440NFC.TIPNFE, E440NFC.CODEDC,

E440NFC.VLRDAR, E440NFC.VLRFUN, E440NFC.VLRBFU,

E440NFC.VLRBIN, E440NFC.VLRINS, E440NFC.VLRBSD,

E440NFC.VLRISD, E440NFC.VERCAL, E440NFC.USUGER,

E440NFC.DATGER, E440NFC.HORGER, E440NFC.CIFFOB,

E440NFC.VLRFRE, E440NFC.VLRSEG, E440NFC.VLREMB,

E440NFC.VLRENC, E440NFC.VLROUT, E440NFC.VLRDAR,

E440NFC.VLRBPI, E440NFC.VLRPIS, E440NFC.CODCPG,

E440NFC.CODTRA, E440NFC.VLRBCR, E440NFC.VLRCOR,

E440NFC.VLRBCT, E440NFC.VLRCRT, E440NFC.VLRBPT,

E440NFC.VLRPIT, E440NFC.VLRBCL, E440NFC.VLRCSL,

E440NFC.VLRBOR, E440NFC.VLROUR, E440NFC.VLRBII,

E440NFC.VLRIIM, E440NFC.NUMDOI, E440NFC.DATDOI,

E440NFC.VLRRIS, E440NFC.CODSEL, E440NFC.CODSSL,

E440NFC.BECIPI, E440NFC.VECIPI, E440NFC.BECICM,

E440NFC.VECICM, E440NFC.SEQORM, E440NFC.PESBRU,

E440NFC.PESLIQ, E440NFC.VLRDPR, E440NFC.VLRDSE,

E440NFC.VLRDZF, E440NFC.VLRDS1, E440NFC.VLRDS2,

E440NFC.VLRDS3, E440NFC.VLRDS4, E440NFC.VLRDS5,

E440NFC.VLRBIE, E440NFC.VLRIEM, E440NFC.PERICF,

E440NFC.ICMFRE, E440NFC.VLRBPF, E440NFC.VLRPIF,

E440NFC.VLRBCF, E440NFC.VLRCFF, E440NFC.CODMS1,

E440NFC.CODMS2, E440NFC.CODMS3, E440NFC.CODMS4,

E440NFC.QTDEMB, E440NFC.UFSCIC, E440NFC.PLAVEI,

E440NFC.CODVIA, E440NFC.CHVNEL, E440NFC.SOMFRE,

E440NFC.BCOIMP, E440NFC.COFIMP, E440NFC.NUMDFS,

E440NFC.CODEMP, E440NFC.BPIIMP, E440NFC.PISIMP,

E440NFC.VLRFEI, E440NFC.VLRSEI, E440NFC.VLROUI,

E440NFC.TIPNDI, E440NFC.CODEQU, E440NFC.NUMCFI,

E440NFC.LOCDES, E440NFC.DATDES, E440NFC.UFSDES,

E440NFC.CODEXP, E440NFC.QTDBIP, E440NFC.QTDBPI,

E440NFC.QTDBCO, E440NFC.QTDBPF, E440NFC.QTDBCF,

E440NFC.VLRLPR, E440NFC.VLRLOU, E440NFC.UFSVEI,

E440NFC.VLRSUB, E440NFC.TOTCIT, E440NFC.VLRSEN,

E440NFC.VLRBSN, E440NFC.VLRAFM, E440NFC.CODFIL,

E440NFC.CODRAI, E440NFC.VLRIBS, E440NFC.VLRISN,

E440NFC.VALNFC, E440NFC.VLRTER, E440NFC.QECIPI,

E440NFC.RAIREM, E440NFC.RAIDES

FROM E440NFC, E020SNF

WHERE E440NFC.CODEMP = {CODEMP} AND

E440NFC.CODFIL = {CODFIL} AND

E440NFC.DATENT >= {DATEMI} AND

E440NFC.DATENT <= {DATENT} AND

E440NFC.SITNFC IN (2,3) AND

E020SNF.CODEMP = E440NFC.CODEMP AND

E020SNF.CODFIL = E440NFC.CODFIL AND

E020SNF.CODSNF = E440NFC.CODSNF AND

E020SNF.UTIIMP = S AND

((E020SNF.DISAUT NOT IN (6, 7, 8, 10, 11)) OR

((E020SNF.DISAUT IN (6, 7, 8, 10, 11)) AND

(E440NFC.TIPNFE NOT IN (3, 6, 7, 10))) OR

(EXISTS (SELECT 1

FROM E140NFV

WHERE E140NFV.CODEMP = E440NFC.CODEMP AND

E140NFV.CODFIL = E440NFC.CODFIL AND

E140NFV.NUMNFV = E440NFC.NUMNFC AND

E140NFV.CODSNF = E440NFC.CODSNF AND

((E020SNF.DISAUT IN (6, 7, 8, 10, 11)) AND

EXISTS (SELECT 1

FROM E140IDE

WHERE E140IDE.CODEMP = E140NFV.CODEMP AND

E140IDE.CODFIL = E140NFV.CODFIL AND

E140IDE.CODSNF = E140NFV.CODSNF AND

E140IDE.NUMNFV = E140NFV.NUMNFV AND

E140IDE.SITDOE = 3)))))

ORDER BY 2, 1, 3, 4, 6

VIteEnt

SELECT SEQIPC, CODPRO, CODDER, CODFAM, CPLIPC, CODCLF,

QTDREC, UNINFC, PERIPI, PERICM, VLRBRU, VLRDSC,

VLRDS1, VLRDS2, VLRDS3, VLRDS4, VLRDS5, VLRDZF,

VLRDAR, VLRBIC, VLRICM, TNSPRO, VLRBSI, VLRIPI,

VLRLPR, VLRICS, VLRBSP, VLRSTP, VLRBSC, VLRSTC,

VLRBID, VLRIPD, VLRBSD, VLRISD, VLRBIP, VLRDFA,

VLRIIC, VLROIC, VLRIIP, VLROIP, VLRLOU, NOPPRO,

VLRFUN, CODSTR, CODTRD, VLRLIQ, CTARED, VLRBPI,

VLRPIS, FILNFV, SNFNFV, NUMNFV, SEQIPV, VLRBCR,

VLRCOR, CODTIC, VLREMB, VLRENC, VLROUT, VLROUD,

CODTST, PERIIM, VLRBII, VLRIIM,VLRFRE, VLRSEG,

VLRRIS, CODBEM, VLRBFU, BECIPI, VECIPI, BECICM,

VECICM, PERPIT, VLRBPT, VLRPIT, PERCRT, VLRBCT,

VLRCRT, PERCSL,VLRBCL, VLRCSL, PEROUR, VLRBOR,

VLROUR, PERIRF, VLRBIR, VLRIRF, EMPNFV, PESBRU,

PESLIQ, PERFUN, VLRBPF, PERPIF, VLRPIF, VLRBCF,

PERCFF, VLRCFF, INTPAT, CSTIPI, CSTPIS, CSTCOF,

CODCCU, PERCIM,BCOIMP, COFIMP, PERPIM, BPIIMP,

PISIMP, VLRFEI, VLRSEI, VLROUI,CODDFS, VLRAJS,

NUMADI, SEQADI, DSCADI, FABEST, PREUNI, QTDBIP,

ALIIPI, QTDBPI, ALIPIS, QTDBCO, ALICOF, QTDBPF,

ALIPIF, QTDBCF, ALICFF, VLRSUB, ORIMER, USUGER,

DATGER, HORGER, PERCIT, VLRCIT, BASCRE, PECICM,

PECIPI, PERSEN, VLRBSN, VLRSEN, PERCOR, PERPIR,

VLRIBS, VLRISN, NUMDRB, VLRAFM, CODDEP, CODEMP,

CODFIL, NUMNFC, CODFOR,

(CASE WHEN MOTDES <> 7 AND ABTDES = ''S'' THEN VLRICD ELSE 0 END) AS VLRICD, CODENQ, ICMAOR, ICMVOR, ICMADE, ICMVDE, CODCES, ICMBDE,

(CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMAFC END) AS ICMAFC,(CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMVFC END) AS ICMVFC,

ACOIMP, APIIMP, QTBCIM, QTBPIM, QECIPI, AECIPI

FROM E440IPC

WHERE CODEMP = {CODEMP} AND

CODFIL = {CODFIL} AND

CODFOR = {CODFOR} AND

NUMNFC = {NUMNFC} AND

CODSNF = {CODSNF} AND

((EXISTS (SELECT 1

FROM E075DER

WHERE E075DER.CODEMP = E440IPC.CODEMP AND

E075DER.CODPRO = E440IPC.CODPRO AND

E075DER.CODDER = E440IPC.CODDER AND

(E075DER.SERMVP = '''' OR E075DER.SERMVP = '' '' OR E075DER.SERMVP IS NULL OR

NOT EXISTS (SELECT 1

FROM E440ISC

WHERE E440ISC.CODEMP = E440IPC.CODEMP AND

E440ISC.CODFIL = E440IPC.CODFIL AND

E440ISC.CODFOR = E440IPC.CODFOR AND

E440ISC.CODSNF = E440IPC.CODSNF AND

E440ISC.NUMNFC = E440IPC.NUMNFC AND

E440ISC.CODSER = E075DER.SERMVP)))) OR

(E440IPC.CODPRO IS NULL OR E440IPC.CODPRO = '''' OR E440IPC.CODPRO = '' ''))

ORDER BY 22, 1

VRatEnt

SELECT CODEMP, CODFIL, NUMNFC, SEQRAT, DATBAS, CRIRAT, CTARED, PERCTA,
VLRCTA, CODCCU, PERRAT, VLRRAT, OBSRAT, NUMPRJ, CODFPJ
FROM E440RAT
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODFOR = {CODFOR} AND
CODSNF = {CODSNF} AND
NUMNFC = {NUMNFC}

VSerEnt

SELECT SEQISC, CODSER, QTDREC, UNIMED, PERISS, VLRISS, VLRLSE,

CODTRI, PERIRF, PERINS, VLRBIS, NOPSER, TNSSER, VLRENC,

VLROUT, VLRDAR, VLRBIR, VLRIRF, VLRBIC, VLRICM, PERICM,

CPLISC, CODCLF, PERIPI, VLRBIP, VLRIPI, VLRBID, VLRIPD,

VLRIIP, VLROIP, VLRLOU, VLRBSI, VLRDSC, VLRDS1, VLRDS2,

VLRDZF, CODSTR, CODTRD, VLRICS, VLRDFA, VLROIC, VLRIIC,

VLRLIQ, VLRBIN, VLRINS, CTARED, VLRBPI, VLRPIS, FILNFV,

SNFNFV, NUMNFV, SEQISV, VLRBCR, VLRCOR, PERCRT, VLRBCT,

VLRCRT, PERPIT, VLRBPT, VLRPIT, PERCSL, VLRBCL, VLRCSL,

PEROUR,VLRBOR, VLROUR, CODTIC, VLROUD, CODTST, VLRRIS,

BECIPI, VECIPI, BECICM, VECICM, EMPNFV, VLRBIE, VLRIEM,

VLRBPF, PERPIF, VLRPIF, VLRBCF, PERCFF, VLRCFF, INTPAT,

CSTIPI, CSTPIS, CSTCOF, CODCCU, BCOIMP, COFIMP, BPIIMP,

PISIMP, CODDFS, VLRAJS, PREUNI, QTDBIP, ALIIPI, QTDBPI,

ALIPIS, QTDBCO, ALICOF, QTDBPF, ALIPIF, QTDBCF, ALICFF,

USUGER, DATGER, HORGER, PERCIT, VLRCIT, ORIMER, BASCRE,

VLRIBS, VLRISN, PECICM, PECIPI, VLRBRU, PERPIR, PERCOR,

BASAPE, PERAPE, VLRAPE, VLRFCP, VSTFCP, CODEMP, CODFIL,

NUMNFC, CODFOR,

(CASE WHEN MOTDES <> 7 AND ABTDES = ''S'' THEN VLRICD ELSE 0 END) AS VLRICD, CODENQ, ICMAOR, ICMVOR, ICMADE, ICMVDE, CODCES, ICMBDE,

(CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMAFC END) AS ICMAFC,(CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMVFC END) AS ICMVFC,

QECIPI, AECIPI, VLRDED

FROM E440ISC

WHERE CODEMP = {CODEMP} AND

CODFIL = {CODFIL} AND

NUMNFC = {NUMNFC} AND

CODFOR = {CODFOR} AND

CODSNF = {CODSNF} AND

(INDINT <> ''S'' OR INDINT IS NULL)

ORDER BY 13, 1

VNotSai

SELECT E140NFV.CODSNF, E140NFV.NUMNFV, E140NFV.CODCLI, E140NFV.TNSPRO, E140NFV.NOPPRO,

E140NFV.TNSSER, E140NFV.NOPSER, E140NFV.DATEMI, E140NFV.DATSAI, E140NFV.VLRLIQ,

E140NFV.VLRBIC, E140NFV.VLRICM, E140NFV.VLRBIP, E140NFV.VLRIPI, E140NFV.SITNFV,

E140NFV.VLRBSI, E140NFV.VLRSIC, E140NFV.VLRBIS, E140NFV.VLRISS, E140NFV.VLRBIR,

E140NFV.VLRIRF, E140NFV.VLRLOU, E140NFV.QTDITP, E140NFV.QTDITS, E140NFV.VLRLPR,

E140NFV.VLRFRE, E140NFV.VLRSEG, E140NFV.VLREMB, E140NFV.VLRENC, E140NFV.VLROUT,

E140NFV.TIPNFS, E140NFV.CODEDC, E140NFV.VLRDAR, E140NFV.VLRBFU, E140NFV.VLRFUN,

E140NFV.CODRAI, E140NFV.VLRBIN, E140NFV.VLRINS, E140NFV.VLRBSD, E140NFV.VLRISD,

E140NFV.CIFFOB, E140NFV.VERCAL, E140NFV.USUGER, E140NFV.DATGER, E140NFV.HORGER,

E140NFV.PERICF, E140NFV.ICMFRE, E140NFV.VLRBPI, E140NFV.VLRPIS, E140NFV.CODCPG,

E140NFV.REMDES, E140NFV.CODCL1, E140NFV.TIPRDE, E140NFV.CGCRDE, E140NFV.INSRDE,

E140NFV.ESTRDE, E140NFV.MUNRDE, E140NFV.CODCL2, E140NFV.CODTRA, E140NFV.PLAVEI,

E140NFV.UFSVEI, E140NFV.KMTDIS, E140NFV.FORCAL, E140NFV.PREIMP, E140NFV.VLRBCR,

E140NFV.VLRCOR, E140NFV.VLRBCT, E140NFV.VLRCRT, E140NFV.VLRBPT, E140NFV.VLRPIT,

E140NFV.VLRBCL, E140NFV.VLRCSL, E140NFV.VLRBOR, E140NFV.VLROUR, E140NFV.VLRBII,

E140NFV.VLRIIM, E140NFV.VLRRIS, E140NFV.NUMRDE, E140NFV.VLRDSE, E140NFV.VLRDPR,

E140NFV.VLRDS1, E140NFV.VLRDS2, E140NFV.VLRDS3, E140NFV.VLRDS4, E140NFV.VLRDZF,

E140NFV.PESBRU, E140NFV.PESLIQ, E140NFV.DATCEX, E140NFV.NUMNSU, E140NFV.DATNSU,

E140NFV.HORNSU, E140NFV.VLRBPF, E140NFV.VLRPIF, E140NFV.VLRBCF, E140NFV.VLRCFF,

E140NFV.CODMS1, E140NFV.CODMS2, E140NFV.CODMS3, E140NFV.CODMS4, E140NFV.SEQENT,

E140NFV.QTDEMB, E140NFV.CODFPG, E140NFV.SNFNCF, E140NFV.NUMNCF, E140NFV.CODFIL,

E140NFV.CODVIA, E140NFV.SEQPCO, E140NFV.SEQPEN, E140NFV.SECCAT, E140NFV.VLRADE,

E140NFV.SOMFRE, E140NFV.CODMTR, E140NFV.HORSAI, E140NFV.TOTCID, E140NFV.CODEMP,

E140NFV.QTDBIP, E140NFV.QTDBPI, E140NFV.QTDBCO, E140NFV.VLRFEI, E140NFV.VLRSEI,

E140NFV.VLROUI, E140NFV.QTDBPF, E140NFV.QTDBCF, E140NFV.VLRSUB, E140NFV.DATIZF,

E140NFV.VLRDED

FROM E020SNF, E140NFV

LEFT OUTER JOIN E140IDE ON E140IDE.CODEMP = E140NFV.CODEMP AND

E140IDE.CODFIL = E140NFV.CODFIL AND

E140IDE.CODSNF = E140NFV.CODSNF AND

E140IDE.NUMNFV = E140NFV.NUMNFV

WHERE E140NFV.CODEMP = {CODEMP} AND

E140NFV.CODFIL = {CODFIL} AND

E140NFV.DATEMI >= {DATSAI} AND

E140NFV.DATEMI <= {DATEMI} AND

E140NFV.SITNFV IN (''2'',''3'') AND

((E140NFV.NOPPRO LIKE ''1%'' OR E140NFV.NOPPRO LIKE ''2%'' OR

E140NFV.NOPPRO LIKE ''3%'' OR E140NFV.NOPPRO LIKE ''4%'' OR

E140NFV.NOPPRO LIKE ''5%'' OR E140NFV.NOPPRO LIKE ''6%'' OR

E140NFV.NOPPRO LIKE ''7%'' OR E140NFV.NOPPRO LIKE ''8%'') OR

(E140NFV.NOPPRO = '' '' AND E140NFV.NOPSER <> '' '')) AND

E020SNF.CODEMP = E140NFV.CODEMP AND

E020SNF.CODFIL = E140NFV.CODFIL AND

E020SNF.CODSNF = E140NFV.CODSNF AND

E020SNF.UTIIMP = ''S'' AND

((E020SNF.DISAUT NOT IN (6, 7, 8, 10, 11)) OR

(E020SNF.DISAUT IN (6, 7, 10, 11) AND EXISTS (SELECT 1 FROM E140IDE

WHERE E140IDE.CODEMP = E140NFV.CODEMP AND

E140IDE.CODFIL = E140NFV.CODFIL AND

E140IDE.CODSNF = E140NFV.CODSNF AND

E140IDE.NUMNFV = E140NFV.NUMNFV AND

E140IDE.SITDOE IN (3, 5, 8, 9))) OR

(E020SNF.DISAUT = 8 AND EXISTS (SELECT 1 FROM E140IDE

WHERE E140IDE.CODEMP = E140NFV.CODEMP AND

E140IDE.CODFIL = E140NFV.CODFIL AND

E140IDE.CODSNF = E140NFV.CODSNF AND

E140IDE.NUMNFV = E140NFV.NUMNFV AND

E140IDE.NUMDFS > 0 AND

E140IDE.DATAUT >= E140NFV.DATEMI)))

AND NOT EXISTS (SELECT 1 FROM E140PMV

WHERE E140PMV.CODEMP = E140NFV.CODEMP AND

E140PMV.CODFIL = E140NFV.CODFIL AND

E140PMV.CODSNF = E140NFV.CODSNF AND

E140PMV.NUMNFV = E140NFV.NUMNFV) AND

NOT EXISTS (SELECT 1 FROM E140PMF

WHERE E140PMF.CODEMP = E140NFV.CODEMP AND

E140PMF.CODFIL = E140NFV.CODFIL AND

E140PMF.CODSNF = E140NFV.CODSNF AND

E140PMF.NUMNFV = E140NFV.NUMNFV) AND

(E140NFV.NUMCFI = 0 OR E140NFV.NUMCFI IS NULL)

ORDER BY 3, 2, 1, 4, 6

VIteSai

SELECT SEQIPV, CODPRO, CODDER, CODFAM, CPLIPV, CODCLF, QTDFAT, UNIMED, PERIPI,

PERICM, VLRBRU, VLRDSC, VLRDS1, VLRDS2, VLRDS3, VLRDS4, VLRDFA, VLRDZF,

VLRDAR, VLRBIC, VLRICM, VLRBSI, TNSPRO, VLRIPI, VLRLPR, VLRBSP, VLRSTP,

VLRBSC, VLRSTC, VLRBID, VLRIPD, VLRICS, VLRBSD, VLRISD, VLRBIP, VLRIIC,

VLROIC, VLRIIP, VLROIP, VLRFRE, VLRSEG, VLREMB, VLRENC, VLROUT, NOPPRO,

CODSTR, CODTRD, VLRLIQ, CTARED, VLRBPI, VLRPIS, FILNFC, CODFOR, NUMNFC,

SNFNFC, SEQIPC, VLRBCR, VLRCOR, CODTIC, VLROUD, CODTST, PERIIM, VLRBII,

VLRIIM, VLRRIS, CODBEM, VLRFUN, VLRBFU, PERFUN, SEQNFI, DESIMP, PERPIT,

VLRBPT, VLRPIT, PERCRT, VLRBCT, VLRCRT, PERCSL, VLRBCL, VLRCSL, PEROUR,

VLRBOR, VLROUR, PERIRF, VLRBIR, VLRIRF, PESBRU, PESLIQ, VLRBPF, PERPIF,

VLRPIF, VLRBCF, PERCFF, VLRCFF, CSTIPI, CSTPIS, CSTCOF, CODCCU, VLRCID,

TOTCID, CODMS1, CODMS2, CODMS3, CODMS4, CODDFS, VLRAJS, PREUNI, QTDBIP,

ALIIPI, QTDBPI, ALIPIS, QTDBCO, ALICOF, VLRFEI, VLRSEI, VLROUI, QTDBPF, ALIPIF,

QTDBCF, ALICFF, VLRSUB, NATPIS, NATCOF, ORIMER, USUGER, DATGER, HORGER,

VLRSEN, VLRBSN, PERSEN, PERISN, VLRIBS, VLRISN, VLRIDV, CODFIL, CODENQ,

ICMAOR, ICMVOR, ICMADE, ICMVDE, CODCES, ICMBDE, UNIVEN, QTDVEN, CODSNF,

CODDEP,

(CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMAFC END) AS ICMAFC,

(CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMVFC END) AS ICMVFC, CODEMP, NUMNFV,

(CASE WHEN MOTDES <> 7 AND ABTDES = ''S'' THEN VLRICD ELSE 0 END) AS VLRICD

FROM E140IPV

WHERE CODEMP =

{CODEMP}

AND

CODFIL =

{CODFIL}

AND

CODSNF =

{CODSNF}

AND

NUMNFV =

{NUMNFV}

ORDER BY 23, 1

VRatSai

SELECT CODEMP, CODFIL, NUMNFV, SEQRAT, DATBAS, CRIRAT, CTARED, PERCTA,
VLRCTA, CODCCU, PERRAT, VLRRAT, OBSRAT, NUMPRJ, CODFPJ
FROM E140RAT
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODSNF = {CODSNF} AND
NUMNFV = {NUMNFV}

VSerSai SELECT SEQISV, CODSER, QTDFAT, UNIMED, VLRBIS, PERISS, VLRISS, VLRLSE, VLRBIR, PERIRF, VLRIRF, VLRBIN, PERINS, VLRINS, CODTRI, NOPSER, VLRLOU, PERICM, CPLISV, CODCLF, PERIPI, VLRBIP, VLRIPI, VLRIIP, VLROIP, VLRBIC, VLRDSC, VLRDS1, VLRDS2, VLRDS3, VLRDS4, VLRDZF, VLRDAR, CODSTR, CODTRD, VLRENC, VLROUT, VLRIIC, VLROIC, VLRBSI, VLRICS, VLRBSD, VLRISD, VLRICM, TNSSER, VLRLIQ, CTARED, VLRBPI, VLRPIS, FILNFC, CODFOR, NUMNFC, SNFNFC, SEQISC, VLRBCR, VLRCOR, PERCRT, VLRBCT, VLRCRT, PERPIT, VLRBPT, VLRPIT, PERCSL, VLRBCL, VLRCSL, PEROUR, VLRBOR, VLROUR, CODTIC, VLROUD, CODTST, VLRRIS, DESIMP, VLRDFA, VLRBPF, PERPIF, VLRPIF, VLRBCF, PERCFF, VLRCFF, CSTIPI, CSTPIS, CSTCOF, CODCCU, CODMS1, CODMS2, CODMS3, CODMS4, CODDFS, VLRAJS, PREUNI, QTDBIP, ALIIPI, QTDBPI, ALIPIS, QTDBCO, ALICOF, QTDBPF, ALIPIF, QTDBCF, ALICFF, NATPIS, NATCOF, USUGER, DATGER, HORGER, ORIMER, PERISN, VLRIBS, VLRISN, VLRBRU, VLRIDV, CODFIL, PERSEN, VLRBSN, VLRSEN, CODENQ, ICMAOR, ICMVOR, VLRAPE, PERAPE, BASAPE, VLRFCP, VSTFCP, ICMADE, ICMVDE, CODCES, ICMBDE, (CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMAFC END) AS ICMAFC, (CASE WHEN COALESCE(VLRRIS, 0) > 0 THEN 0 ELSE ICMVFC END) AS ICMVFC, NUMNFV, (CASE WHEN MOTDES <> 7 AND ABTDES = ''S'' THEN VLRICD ELSE 0 END) AS VLRICD, CODSNF, CODEMP, VLRDED FROM E140ISV WHERE CODEMP = {CODEMP} AND CODFIL = {CODFIL} AND CODSNF = {CODSNF} AND NUMNFV = {NUMNFV} AND (INDINT <> ''S'' OR INDINT IS NULL) ORDER BY 33, 1
VConTra CSELECT SEQCCT, DATEMI, CODEDC, CODSEL, CODSSL, NUMNFT,
VLRTOT, QTDMER, QTDVOL, UNIMED, CHVNEL, VLRMER, PESBRU, PESLIQ
FROM E140CCT
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODSNF = {CODSNF} AND
NUMNFV = {NUMNFV}
VProSer SELECT SEQIPV, SEQLPS, EMPRLC, FILRLC, SNFRLC, NFVRLC, ISVRLC
FROM E140LPS
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODSNF = {CODSNF} AND
NUMNFV = {NUMNFV}
VProLns SELECT SEQIPV, SEQLNP, EMPRLC, FILRLC, SNFRLC, NFVRLC, IPVRLC
FROM E140LNP
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODSNF = {CODSNF} AND
NUMNFV = {NUMNFV}
VSerLns SELECT SEQISV, SEQLNS, EMPRLC, FILRLC, SNFRLC, NFVRLC, ISVRLC
FROM E140LNS
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODSNF = {CODSNF} AND
NUMNFV = {NUMNFV}
VProLne SELECT SEQIPC, SEQLNP, EMPRLC, FILRLC, FORRLC, SNFRLC, NFCRLC, IPCRLC
FROM E440LNP
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODFOR = {CODFOR} AND
CODSNF = {CODSNF} AND
NUMNFC = {NUMNFC}
VSerLne SELECT SEQISC, SEQLNS, EMPRLC, FILRLC, FORRLC, SNFRLC, NFCRLC, ISCRLC
FROM E440LNS
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODFOR = {CODFOR} AND
CODSNF = {CODSNF} AND
NUMNFC = {NUMNFC}
VParSai

SELECT CODPAR, NUMTIT, CODTPT, VCTPAR, VLRPAR, OBSPAR, CODFPG,
USUGER, DATGER, HORGER, TIPCAR
FROM E140PAR
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODSNF = {CODSNF} AND
NUMNFV = {NUMNFV}

VParEnt SELECT CODPAR, NUMTIT, CODTPT, VCTPAR, VLRPAR, OBSPAR, USUGER, DATGER, HORGER
FROM E440PAR
WHERE CODEMP = {CODEMP} AND
CODFIL = {CODFIL} AND
CODFOR = {CODFOR} AND
CODSNF = {CODSNF} AND
NUMNFC = {NUMNFC}
VLotSai SELECT E140DLS.DATENT, E140DLS.OBSDLS, E140DLS.SEQIPV, E140DLS.SEQDLS, E140DLS.NUMSEP, E140DLS.CODDEP, E140DLS.CODLOT, E140DLS.DATVLT, E140DLS.QTDEST, E140IPV.CODPRO, E140IPV.CODDER FROM E140IPV, E140DLS WHERE E140IPV.CODEMP = {CODEMP} AND E140IPV.CODFIL = {CODFIL} AND E140IPV.NUMNFV = {NUMNFV} AND E140IPV.CODSNF = {CODSNF} AND E140IPV.CODEMP = E140DLS.CODEMP AND E140IPV.CODFIL = E140DLS.CODFIL AND E140IPV.CODSNF = E140DLS.CODSNF AND E140IPV.NUMNFV = E140DLS.NUMNFV AND E140IPV.SEQIPV = E140DLS.SEQIPV
VLotEnt SELECT E440DLS.DATENT, E440DLS.OBSDLS, E440DLS.SEQIPC, E440DLS.SEQDLS, E440DLS.NUMSEP, E440DLS.CODFOR, E440DLS.CODSNF, E440DLS.NUMNFC, E440DLS.CODDEP, E440DLS.CODLOT, E440DLS.QTDEST, E440IPC.CODPRO, E440IPC.CODDER, E440DLS.DATVLT, E440DLS.CODEMP, E440DLS.CODFIL FROM E440IPC, E440DLS WHERE E440IPC.CODEMP = {CODEMP} AND E440IPC.CODFIL = {CODFIL} AND E440IPC.NUMNFC = {NUMNFC} AND E440IPC.CODSNF = {CODSNF} AND E440IPC.CODFOR = {CODFOR} AND E440IPC.CODEMP = E440DLS.CODEMP AND E440IPC.CODFIL = E440DLS.CODFIL AND E440IPC.CODFOR = E440DLS.CODFOR AND E440IPC.CODSNF = E440DLS.CODSNF AND E440IPC.NUMNFC = E440DLS.NUMNFC AND E440IPC.SEQIPC = E440DLS.SEQIPC
IMPALIGDPR SELECT E440DPR.CODEMP,E440DPR.CODFIL,
E440DPR.CODFOR,E440DPR.NUMNFC,E440DPR.CODSNF,E440DPR.SEQDPR,E440DPR.UFSDPR,
E440DPR.DATDPR,E440DPR.FORDPR,E440DPR.CODEDC,E440DPR.SNFDPR,E440DPR.NUMDPR
FROM E440DPR
WHERE E440DPR.CODEMP = {CODEMP} AND
E440DPR.CODFIL = {CODFIL} AND
E440DPR.CODFOR = {CODFOR} AND
E440DPR.NUMNFC = {NUMNFC} AND
E440DPR.CODSNF = {CODSNF}
IMPAIDEDOE

SELECT CODEMP, CODFIL, CODSNF, NUMNFV, SITDOE, SITDEA, CHVDOE,
NUMDFS, CODVER, NUMPRT, DATAUT, HORAUT, USUEMI, NUMPRC,
DATCAN, HORCAN, USUCAN, NUMPRI, DATINU, HORINU, USUINU,
REAPED, REAPFA, REATCK, REACOL, CHVCTG, DATCTG, HORCTG,
MOTCTG, OBSCTG
FROM E140IDE
WHERE E140IDE.CODEMP = {CODEMP} AND
E140IDE.CODFIL = {CODFIL} AND
E140IDE.CODSNF = {CODSNF} AND
E140IDE.NUMNFV = {NUMNFV}

VExcEnt Banco de dados Oracle DELETE FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660NFC.CODEMP AND E440NFC.CODFIL = E660NFC.CODFIL AND E440NFC.CODFOR = E660NFC.CODFOR AND E440NFC.NUMNFC = E660NFC.NUMNFI AND E440NFC.CODSNF = E660NFC.CODSNF) Banco de dados Sql Server DELETE FROM E660NFC FROM E660NFC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660NFC.CODEMP AND E440NFC.CODFIL = E660NFC.CODFIL AND E440NFC.CODFOR = E660NFC.CODFOR AND E440NFC.CODSNF = E660NFC.CODSNF AND E440NFC.NUMNFC = E660NFC.NUMNFI WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0
VExcIte Banco de dados Oracle DELETE FROM E660INC WHERE E660INC.CODEMP = {1} AND E660INC.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660INC.CODEMP AND E440NFC.CODFIL = E660INC.CODFIL AND E440NFC.CODFOR = E660INC.CODFOR AND E440NFC.NUMNFC = E660INC.NUMNFI AND E440NFC.CODSNF = E660INC.CODSNF) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660INC.CODEMP AND E660NFC.CODFIL = E660INC.CODFIL AND E660NFC.CODFOR = E660INC.CODFOR AND E660NFC.NUMNFI = E660INC.NUMNFI AND E660NFC.NUMNFF = E660INC.NUMNFF AND E660NFC.CODSNF = E660INC.CODSNF AND E660NFC.CODTNS = E660INC.CODTNS AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660INC FROM E660INC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660INC.CODEMP AND E440NFC.CODFIL = E660INC.CODFIL AND E440NFC.CODFOR = E660INC.CODFOR AND E440NFC.CODSNF = E660INC.CODSNF AND E440NFC.NUMNFC = E660INC.NUMNFI INNER JOIN E660NFC ON E660NFC.CODEMP = E660INC.CODEMP AND E660NFC.CODFIL = E660INC.CODFIL AND E660NFC.CODFOR = E660INC.CODFOR AND E660NFC.NUMNFI = E660INC.NUMNFI AND E660NFC.NUMNFF = E660INC.NUMNFF AND E660NFC.CODSNF = E660INC.CODSNF AND E660NFC.CODTNS = E660INC.CODTNS AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 WHERE E660INC.CODEMP = {1} AND E660INC.CODFIL = {2}
VExcRtc Banco de dados Oracle DELETE FROM E660RTC WHERE E660RTC.CODEMP = {1} AND E660RTC.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660RTC.CODEMP AND E440NFC.CODFIL = E660RTC.CODFIL AND E440NFC.CODFOR = E660RTC.CODFOR AND E440NFC.NUMNFC = E660RTC.NUMNFI AND E440NFC.CODSNF = E660RTC.CODSNF) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660RTC.CODEMP AND E660NFC.CODFIL = E660RTC.CODFIL AND E660NFC.CODFOR = E660RTC.CODFOR AND E660NFC.NUMNFI = E660RTC.NUMNFI AND E660NFC.NUMNFF = E660RTC.NUMNFF AND E660NFC.CODSNF = E660RTC.CODSNF AND E660NFC.CODTNS = E660RTC.CODTNS AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660RTC FROM E660RTC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660RTC.CODEMP AND E440NFC.CODFIL = E660RTC.CODFIL AND E440NFC.CODFOR = E660RTC.CODFOR AND E440NFC.CODSNF = E660RTC.CODSNF AND E440NFC.NUMNFC = E660RTC.NUMNFI INNER JOIN E660NFC ON E660NFC.CODEMP = E660RTC.CODEMP AND E660NFC.CODFIL = E660RTC.CODFIL AND E660NFC.CODFOR = E660RTC.CODFOR AND E660NFC.NUMNFI = E660RTC.NUMNFI AND E660NFC.NUMNFF = E660RTC.NUMNFF AND E660NFC.CODSNF = E660RTC.CODSNF AND E660NFC.CODTNS = E660RTC.CODTNS AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 WHERE E660RTC.CODEMP = {1} AND E660RTC.CODFIL = {2}
VExcCip Banco de dados Oracle DELETE FROM E660CIP WHERE E660CIP.CODEMP = {1} AND E660CIP.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660CIP.CODEMP AND E440NFC.CODFIL = E660CIP.CODFIL AND E440NFC.CODFOR = E660CIP.CODFOR AND E440NFC.NUMNFC = E660CIP.NUMNFI AND E440NFC.CODSNF = E660CIP.CODSNF) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660CIP.CODEMP AND E660NFC.CODFIL = E660CIP.CODFIL AND E660NFC.CODFOR = E660CIP.CODFOR AND E660NFC.NUMNFI = E660CIP.NUMNFI AND E660NFC.NUMNFF = E660CIP.NUMNFF AND E660NFC.CODSNF = E660CIP.CODSNF AND E660NFC.CODTNS = E660CIP.CODTNS AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660CIP FROM E660CIP WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660CIP.CODEMP AND E440NFC.CODFIL = E660CIP.CODFIL AND E440NFC.CODFOR = E660CIP.CODFOR AND E440NFC.CODSNF = E660CIP.CODSNF AND E440NFC.NUMNFC = E660CIP.NUMNFI INNER JOIN E660NFC ON E660NFC.CODEMP = E660CIP.CODEMP AND E660NFC.CODFIL = E660CIP.CODFIL AND E660NFC.CODFOR = E660CIP.CODFOR AND E660NFC.NUMNFI = E660CIP.NUMNFI AND E660NFC.NUMNFF = E660CIP.NUMNFF AND E660NFC.CODSNF = E660CIP.CODSNF AND E660NFC.CODTNS = E660CIP.CODTNS AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 WHERE E660CIP.CODEMP = {1} AND E660CIP.CODFIL = {2}
VExcDlc Banco de dados Oracle DELETE FROM E660DLC WHERE E660DLC.CODEMP = {1} AND E660DLC.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660DLC.CODEMP AND E440NFC.CODFIL = E660DLC.CODFIL AND E440NFC.CODFOR = E660DLC.CODFOR AND E440NFC.CODSNF = E660DLC.CODSNF AND E440NFC.NUMNFC = E660DLC.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660DLC.CODEMP AND E660NFC.CODFIL = E660DLC.CODFIL AND E660NFC.CODFOR = E660DLC.CODFOR AND E660NFC.CODSNF = E660DLC.CODSNF AND E660NFC.NUMNFI = E660DLC.NUMNFI AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) AND EXISTS (SELECT 1 FROM E440DLS WHERE E440DLS.CODEMP = {1} AND E440DLS.CODFIL = {2} AND E440DLS.CODEMP = E660DLC.CODEMP AND E440DLS.CODFIL = E660DLC.CODFIL AND E440DLS.CODFOR = E660DLC.CODFOR AND E440DLS.CODSNF = E660DLC.CODSNF AND E440DLS.NUMNFC = E660DLC.NUMNFI AND E440DLS.SEQIPC = E660DLC.SEQIPC AND E440DLS.SEQDLS = E660DLC.SEQDLS) Banco de dados Sql Server DELETE FROM E660DLC FROM E660DLC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660DLC.CODEMP AND E440NFC.CODFIL = E660DLC.CODFIL AND E440NFC.CODFOR = E660DLC.CODFOR AND E440NFC.CODSNF = E660DLC.CODSNF AND E440NFC.NUMNFC = E660DLC.NUMNFI MontarAbrangenciaFiltrosNotasFiscaisCompras(mtComercial) + INNER JOIN E660NFC ON E660NFC.CODEMP = E660DLC.CODEMP AND E660NFC.CODFIL = E660DLC.CODFIL AND E660NFC.CODFOR = E660DLC.CODFOR AND E660NFC.CODSNF = E660DLC.CODSNF AND E660NFC.NUMNFI = E660DLC.NUMNFI AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 INNER JOIN E440DLS ON E440DLS.CODEMP = E660DLC.CODEMP AND E440DLS.CODFIL = E660DLC.CODFIL AND E440DLS.CODFOR = E660DLC.CODFOR AND E440DLS.CODSNF = E660DLC.CODSNF AND E440DLS.NUMNFC = E660DLC.NUMNFI AND E440DLS.SEQIPC = E660DLC.SEQIPC AND E440DLS.SEQDLS = E660DLC.SEQDLS AND E440DLS.CODEMP = E660NFC.CODEMP AND E440DLS.CODFIL = E660NFC.CODFIL AND E440DLS.CODFOR = E660NFC.CODFOR AND E440DLS.CODSNF = E660NFC.CODSNF AND E440DLS.NUMNFC = E660NFC.NUMNFI AND E440DLS.CODEMP = E440NFC.CODEMP AND E440DLS.CODFIL = E440NFC.CODFIL AND E440DLS.CODFOR = E440NFC.CODFOR AND E440DLS.CODSNF = E440NFC.CODSNF AND E440DLS.NUMNFC = E440NFC.NUMNFC WHERE E660DLC.CODEMP = {1} AND E660DLC.CODFIL = {2}
VExcPac Banco de dados Oracle DELETE FROM E660PAC WHERE E660PAC.CODEMP = {1} AND E660PAC.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660PAC.CODEMP AND E440NFC.CODFIL = E660PAC.CODFIL AND E440NFC.CODFOR = E660PAC.CODFOR AND E440NFC.CODSNF = E660PAC.CODSNF AND E440NFC.NUMNFC = E660PAC.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660PAC.CODEMP AND E660NFC.CODFIL = E660PAC.CODFIL AND E660NFC.CODFOR = E660PAC.CODFOR AND E660NFC.CODSNF = E660PAC.CODSNF AND E660NFC.NUMNFI = E660PAC.NUMNFI AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) AND EXISTS (SELECT 1 FROM E440PAR WHERE E440PAR.CODEMP = {1} AND E440PAR.CODFIL = {2} AND E440PAR.CODEMP = E660PAC.CODEMP AND E440PAR.CODFIL = E660PAC.CODFIL AND E440PAR.CODFOR = E660PAC.CODFOR AND E440PAR.CODSNF = E660PAC.CODSNF AND E440PAR.NUMNFC = E660PAC.NUMNFI AND E440PAR.CODPAR = E660PAC.CODPAR) Banco de dados Sql Server DELETE FROM E660PAC FROM E660PAC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660PAC.CODEMP AND E440NFC.CODFIL = E660PAC.CODFIL AND E440NFC.CODFOR = E660PAC.CODFOR AND E440NFC.CODSNF = E660PAC.CODSNF AND E440NFC.NUMNFC = E660PAC.NUMNFI MontarAbrangenciaFiltrosNotasFiscaisCompras(mtComercial) + INNER JOIN E660NFC ON E660NFC.CODEMP = E660PAC.CODEMP AND E660NFC.CODFIL = E660PAC.CODFIL AND E660NFC.CODFOR = E660PAC.CODFOR AND E660NFC.CODSNF = E660PAC.CODSNF AND E660NFC.NUMNFI = E660PAC.NUMNFI AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 INNER JOIN E440PAR ON E440PAR.CODEMP = E660PAC.CODEMP AND E440PAR.CODFIL = E660PAC.CODFIL AND E440PAR.CODFOR = E660PAC.CODFOR AND E440PAR.CODSNF = E660PAC.CODSNF AND E440PAR.NUMNFC = E660PAC.NUMNFI AND E440PAR.CODPAR = E660PAC.CODPAR AND E440PAR.CODEMP = E660NFC.CODEMP AND E440PAR.CODFIL = E660NFC.CODFIL AND E440PAR.CODFOR = E660NFC.CODFOR AND E440PAR.CODSNF = E660NFC.CODSNF AND E440PAR.NUMNFC = E660NFC.NUMNFI AND E440PAR.CODEMP = E440NFC.CODEMP AND E440PAR.CODFIL = E440NFC.CODFIL AND E440PAR.CODFOR = E440NFC.CODFOR AND E440PAR.CODSNF = E440NFC.CODSNF AND E440PAR.NUMNFC = E440NFC.NUMNFC WHERE E660PAC.CODEMP = {1} AND E660PAC.CODFIL = {2}
VExcLnc Banco de dados Oracle DELETE FROM E660LNC WHERE E660LNC.CODEMP = {1} AND E660LNC.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660LNC.CODEMP AND E440NFC.CODFIL = E660LNC.CODFIL AND E440NFC.CODFOR = E660LNC.CODFOR AND E440NFC.CODSNF = E660LNC.CODSNF AND E440NFC.NUMNFC = E660LNC.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660LNC.CODEMP AND E660NFC.CODFIL = E660LNC.CODFIL AND E660NFC.CODFOR = E660LNC.CODFOR AND E660NFC.CODSNF = E660LNC.CODSNF AND E660NFC.NUMNFI = E660LNC.NUMNFI AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) AND (EXISTS (SELECT 1 FROM E440LNP WHERE E440LNP.CODEMP = {1} AND E440LNP.CODFIL = {2} AND E440LNP.CODEMP = E660LNC.CODEMP AND E440LNP.CODFIL = E660LNC.CODFIL AND E440LNP.CODFOR = E660LNC.CODFOR AND E440LNP.CODSNF = E660LNC.CODSNF AND E440LNP.NUMNFC = E660LNC.NUMNFI AND E440LNP.SEQIPC = E660LNC.SEQIPC) OR EXISTS (SELECT 1 FROM E440LNS WHERE E440LNS.CODEMP = {1} AND E440LNS.CODFIL = {2} AND E440LNS.CODEMP = E660LNC.CODEMP AND E440LNS.CODFIL = E660LNC.CODFIL AND E440LNS.CODFOR = E660LNC.CODFOR AND E440LNS.CODSNF = E660LNC.CODSNF AND E440LNS.NUMNFC = E660LNC.NUMNFI AND E440LNS.SEQISC = E660LNC.SEQIPC) OR EXISTS (SELECT 1 FROM E660DGC WHERE E660DGC.CODEMP = {1} AND E660DGC.CODFIL = {2} AND E660DGC.CODEMP = E660LNC.CODEMP AND E660DGC.CODFIL = E660LNC.CODFIL AND E660DGC.CODFOR = E660LNC.CODFOR AND E660DGC.CODSNF = E660LNC.CODSNF AND E660DGC.NUMNFI = E660LNC.NUMNFI)) Banco de dados Sql Server DELETE FROM E660LNC FROM E660LNC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660LNC.CODEMP AND E440NFC.CODFIL = E660LNC.CODFIL AND E440NFC.CODFOR = E660LNC.CODFOR AND E440NFC.CODSNF = E660LNC.CODSNF AND E440NFC.NUMNFC = E660LNC.NUMNFI MontarAbrangenciaFiltrosNotasFiscaisCompras(mtComercial) + INNER JOIN E660NFC ON E660NFC.CODEMP = E660LNC.CODEMP AND E660NFC.CODFIL = E660LNC.CODFIL AND E660NFC.CODFOR = E660LNC.CODFOR AND E660NFC.CODSNF = E660LNC.CODSNF AND E660NFC.NUMNFI = E660LNC.NUMNFI AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 INNER JOIN ( SELECT CODEMP, CODFIL, CODFOR, CODSNF, NUMNFC, SEQIPC AS SEQITE FROM E440LNP WHERE CODEMP = {1} AND CODFIL = {2} UNION ALL SELECT CODEMP, CODFIL, CODFOR, CODSNF, NUMNFC, SEQISC AS SEQITE FROM E440LNS WHERE CODEMP = {1} AND CODFIL = {2} UNION ALL SELECT CODEMP, CODFIL, CODFOR, CODSNF, NUMNFI AS NUMNFC, 0 AS SEQITE FROM E660DGC WHERE CODEMP = {1} AND CODFIL = {2} ) TABELA ON TABELA.CODEMP = E660LNC.CODEMP AND TABELA.CODFIL = E660LNC.CODFIL AND TABELA.CODFOR = E660LNC.CODFOR AND TABELA.CODSNF = E660LNC.CODSNF AND TABELA.NUMNFC = E660LNC.NUMNFI AND (TABELA.SEQITE = E660LNC.SEQIPC OR TABELA.SEQITE = 0) AND TABELA.CODEMP = E660NFC.CODEMP AND TABELA.CODFIL = E660NFC.CODFIL AND TABELA.CODFOR = E660NFC.CODFOR AND TABELA.CODSNF = E660NFC.CODSNF AND TABELA.NUMNFC = E660NFC.NUMNFI AND TABELA.CODEMP = E440NFC.CODEMP AND TABELA.CODFIL = E440NFC.CODFIL AND TABELA.CODFOR = E440NFC.CODFOR AND TABELA.CODSNF = E440NFC.CODSNF AND TABELA.NUMNFC = E440NFC.NUMNFC WHERE E660LNC.CODEMP = {1} AND E660LNC.CODFIL = {2}
VExcDgc Banco de dados Oracle DELETE FROM E660DGC WHERE E660DGC.CODEMP = {1} AND E660DGC.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = {1} AND E440NFC.CODFIL = {2} AND E440NFC.CODEMP = E660DGC.CODEMP AND E440NFC.CODFIL = E660DGC.CODFIL AND E440NFC.CODFOR = E660DGC.CODFOR AND E440NFC.CODSNF = E660DGC.CODSNF AND E440NFC.NUMNFC = E660DGC.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = {1} AND E660NFC.CODFIL = {2} AND E660NFC.CODEMP = E660DGC.CODEMP AND E660NFC.CODFIL = E660DGC.CODFIL AND E660NFC.CODFOR = E660DGC.CODFOR AND E660NFC.CODSNF = E660DGC.CODSNF AND E660NFC.NUMNFI = E660DGC.NUMNFI AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660DGC FROM E660DGC WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660DGC.CODEMP AND E440NFC.CODFIL = E660DGC.CODFIL AND E440NFC.CODFOR = E660DGC.CODFOR AND E440NFC.CODSNF = E660DGC.CODSNF AND E440NFC.NUMNFC = E660DGC.NUMNFI INNER JOIN E660NFC ON E660NFC.CODEMP = E660DGC.CODEMP AND E660NFC.CODFIL = E660DGC.CODFIL AND E660NFC.CODFOR = E660DGC.CODFOR AND E660NFC.CODSNF = E660DGC.CODSNF AND E660NFC.NUMNFI = E660DGC.NUMNFI AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 WHERE E660DGC.CODEMP = {1} AND E660DGC.CODFIL = {2}
VExcSai Banco de dados Oracle DELETE FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660NFV.CODEMP AND E140NFV.CODFIL = E660NFV.CODFIL AND E140NFV.CODSNF = E660NFV.CODSNF AND E140NFV.NUMNFV = E660NFV.NUMNFI) Banco de dados Sql Server 'DELETE FROM E660NFV FROM E660NFV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660NFV.CODEMP AND E140NFV.CODFIL = E660NFV.CODFIL AND E140NFV.CODSNF = E660NFV.CODSNF AND E140NFV.NUMNFV = E660NFV.NUMNFI WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0
VExcIts Banco de dados Oracle DELETE FROM E660INV WHERE E660INV.CODEMP = {1} AND E660INV.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660INV.CODEMP AND E140NFV.CODFIL = E660INV.CODFIL AND E140NFV.CODSNF = E660INV.CODSNF AND E140NFV.NUMNFV = E660INV.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660INV.CODEMP AND E660NFV.CODFIL = E660INV.CODFIL AND E660NFV.CODSNF = E660INV.CODSNF AND E660NFV.NUMNFI = E660INV.NUMNFI AND E660NFV.NUMNFF = E660INV.NUMNFF AND E660NFV.CODTNS = E660INV.CODTNS AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660INV FROM E660INV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660INV.CODEMP AND E140NFV.CODFIL = E660INV.CODFIL AND E140NFV.CODSNF = E660INV.CODSNF AND E140NFV.NUMNFV = E660INV.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660INV.CODEMP AND E660NFV.CODFIL = E660INV.CODFIL AND E660NFV.CODCLI = E660INV.CODCLI AND E660NFV.NUMNFI = E660INV.NUMNFI AND E660NFV.NUMNFF = E660INV.NUMNFF AND E660NFV.CODSNF = E660INV.CODSNF AND E660NFV.CODTNS = E660INV.CODTNS AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 WHERE E660INV.CODEMP = {1} AND E660INV.CODFIL = {2}
VExcRtv Banco de dados Oracle DELETE FROM E660RTV WHERE E660RTV.CODEMP = {1} AND E660RTV.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660RTV.CODEMP AND E140NFV.CODFIL = E660RTV.CODFIL AND E140NFV.CODSNF = E660RTV.CODSNF AND E140NFV.NUMNFV = E660RTV.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660RTV.CODEMP AND E660NFV.CODFIL = E660RTV.CODFIL AND E660NFV.CODSNF = E660RTV.CODSNF AND E660NFV.NUMNFI = E660RTV.NUMNFI AND E660NFV.NUMNFF = E660RTV.NUMNFF AND E660NFV.CODTNS = E660RTV.CODTNS AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660RTV FROM E660RTV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660RTV.CODEMP AND E140NFV.CODFIL = E660RTV.CODFIL AND E140NFV.CODSNF = E660RTV.CODSNF AND E140NFV.NUMNFV = E660RTV.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660RTV.CODEMP AND E660NFV.CODFIL = E660RTV.CODFIL AND E660NFV.CODCLI = E660RTV.CODCLI AND E660NFV.NUMNFI = E660RTV.NUMNFI AND E660NFV.NUMNFF = E660RTV.NUMNFF AND E660NFV.CODSNF = E660RTV.CODSNF AND E660NFV.CODTNS = E660RTV.CODTNS AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 WHERE E660RTV.CODEMP = {1} AND E660RTV.CODFIL = {2}
VExcCct Banco de dados Oracle DELETE FROM E660CCT WHERE E660CCT.CODEMP = {1} AND E660CCT.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660CCT.CODEMP AND E140NFV.CODFIL = E660CCT.CODFIL AND E140NFV.CODSNF = E660CCT.CODSNF AND E140NFV.NUMNFV = E660CCT.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660CCT.CODEMP AND E660NFV.CODFIL = E660CCT.CODFIL AND E660NFV.CODSNF = E660CCT.CODSNF AND E660NFV.NUMNFI = E660CCT.NUMNFI AND E660NFV.NUMNFF = E660CCT.NUMNFF AND E660NFV.CODTNS = E660CCT.CODTNS AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660CCT FROM E660CCT WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660CCT.CODEMP AND E140NFV.CODFIL = E660CCT.CODFIL AND E140NFV.CODSNF = E660CCT.CODSNF AND E140NFV.NUMNFV = E660CCT.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660CCT.CODEMP AND E660NFV.CODFIL = E660CCT.CODFIL AND E660NFV.CODCLI = E660CCT.CODCLI AND E660NFV.NUMNFI = E660CCT.NUMNFI AND E660NFV.NUMNFF = E660CCT.NUMNFF AND E660NFV.CODSNF = E660CCT.CODSNF AND E660NFV.CODTNS = E660CCT.CODTNS AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 WHERE E660CCT.CODEMP = {1} AND E660CCT.CODFIL = {2}
VExcDlv Banco de dados Oracle DELETE FROM E660DLV WHERE E660DLV.CODEMP = {1} AND E660DLV.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660DLV.CODEMP AND E140NFV.CODFIL = E660DLV.CODFIL AND E140NFV.CODSNF = E660DLV.CODSNF AND E140NFV.NUMNFV = E660DLV.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660DLV.CODEMP AND E660NFV.CODFIL = E660DLV.CODFIL AND E660NFV.CODSNF = E660DLV.CODSNF AND E660NFV.NUMNFI = E660DLV.NUMNFI AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) AND EXISTS (SELECT 1 FROM E140DLS WHERE E140DLS.CODEMP = {1} AND E140DLS.CODFIL = {2} AND E140DLS.CODEMP = E660DLV.CODEMP AND E140DLS.CODFIL = E660DLV.CODFIL AND E140DLS.CODSNF = E660DLV.CODSNF AND E140DLS.NUMNFV = E660DLV.NUMNFI AND E140DLS.SEQIPV = E660DLV.SEQIPV AND E140DLS.SEQDLS = E660DLV.SEQDLS) Banco de dados Sql Server DELETE FROM E660DLV FROM E660DLV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660DLV.CODEMP AND E140NFV.CODFIL = E660DLV.CODFIL AND E140NFV.CODSNF = E660DLV.CODSNF AND E140NFV.NUMNFV = E660DLV.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660DLV.CODEMP AND E660NFV.CODFIL = E660DLV.CODFIL AND E660NFV.CODSNF = E660DLV.CODSNF AND E660NFV.NUMNFI = E660DLV.NUMNFI AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 INNER JOIN E140DLS ON E140DLS.CODEMP = E660DLV.CODEMP AND E140DLS.CODFIL = E660DLV.CODFIL AND E140DLS.CODSNF = E660DLV.CODSNF AND E140DLS.NUMNFV = E660DLV.NUMNFI AND E140DLS.SEQIPV = E660DLV.SEQIPV AND E140DLS.SEQDLS = E660DLV.SEQDLS WHERE E660DLV.CODEMP = {1} AND E660DLV.CODFIL = {2}
VExcPav Banco de dados Oracle DELETE FROM E660PAV WHERE E660PAV.CODEMP = {1} AND E660PAV.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660PAV.CODEMP AND E140NFV.CODFIL = E660PAV.CODFIL AND E140NFV.CODSNF = E660PAV.CODSNF AND E140NFV.NUMNFV = E660PAV.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660PAV.CODEMP AND E660NFV.CODFIL = E660PAV.CODFIL AND E660NFV.CODSNF = E660PAV.CODSNF AND E660NFV.NUMNFI = E660PAV.NUMNFI AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) AND EXISTS (SELECT 1 FROM E140PAR WHERE E140PAR.CODEMP = {1} AND E140PAR.CODFIL = {2} AND E140PAR.CODEMP = E660PAV.CODEMP AND E140PAR.CODFIL = E660PAV.CODFIL AND E140PAR.CODSNF = E660PAV.CODSNF AND E140PAR.NUMNFV = E660PAV.NUMNFI AND E140PAR.CODPAR = E660PAV.CODPAR) Banco de dados Sql Server DELETE FROM E660PAV FROM E660PAV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660PAV.CODEMP AND E140NFV.CODFIL = E660PAV.CODFIL AND E140NFV.CODSNF = E660PAV.CODSNF AND E140NFV.NUMNFV = E660PAV.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660PAV.CODEMP AND E660NFV.CODFIL = E660PAV.CODFIL AND E660NFV.CODSNF = E660PAV.CODSNF AND E660NFV.NUMNFI = E660PAV.NUMNFI AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 INNER JOIN E140PAR ON E140PAR.CODEMP = E660PAV.CODEMP AND E140PAR.CODFIL = E660PAV.CODFIL AND E140PAR.CODSNF = E660PAV.CODSNF AND E140PAR.NUMNFV = E660PAV.NUMNFI AND E140PAR.CODPAR = E660PAV.CODPAR AND E140PAR.CODEMP = E660NFV.CODEMP AND E140PAR.CODFIL = E660NFV.CODFIL AND E140PAR.CODSNF = E660NFV.CODSNF AND E140PAR.NUMNFV = E660NFV.NUMNFI AND E140PAR.CODEMP = E140NFV.CODEMP AND E140PAR.CODFIL = E140NFV.CODFIL AND E140PAR.CODSNF = E140NFV.CODSNF AND E140PAR.NUMNFV = E140NFV.NUMNFV WHERE E660PAV.CODEMP = {1} AND E660PAV.CODFIL = {2}
VExcLnv Banco de dados Oracle DELETE FROM E660LNV WHERE E660LNV.CODEMP = {1} AND E660LNV.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660LNV.CODEMP AND E140NFV.CODFIL = E660LNV.CODFIL AND E140NFV.CODSNF = E660LNV.CODSNF AND E140NFV.NUMNFV = E660LNV.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660LNV.CODEMP AND E660NFV.CODFIL = E660LNV.CODFIL AND E660NFV.CODSNF = E660LNV.CODSNF AND E660NFV.NUMNFI = E660LNV.NUMNFI AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) AND (EXISTS (SELECT 1 FROM E140LPS WHERE E140LPS.CODEMP = {1} AND E140LPS.CODFIL = {2} AND E140LPS.CODEMP = E660LNV.CODEMP AND E140LPS.CODFIL = E660LNV.CODFIL AND E140LPS.CODSNF = E660LNV.CODSNF AND E140LPS.NUMNFV = E660LNV.NUMNFI AND E140LPS.SEQIPV = E660LNV.SEQIPV) OR EXISTS (SELECT 1 FROM E140LNP WHERE E140LNP.CODEMP = {1} AND E140LNP.CODFIL = {2} AND E140LNP.CODEMP = E660LNV.CODEMP AND E140LNP.CODFIL = E660LNV.CODFIL AND E140LNP.CODSNF = E660LNV.CODSNF AND E140LNP.NUMNFV = E660LNV.NUMNFI AND E140LNP.SEQIPV = E660LNV.SEQIPV) OR EXISTS (SELECT 1 FROM E140LNS WHERE E140LNS.CODEMP = {1} AND E140LNS.CODFIL = {2} AND E140LNS.CODEMP = E660LNV.CODEMP AND E140LNS.CODFIL = E660LNV.CODFIL AND E140LNS.CODSNF = E660LNV.CODSNF AND E140LNS.NUMNFV = E660LNV.NUMNFI AND E140LNS.SEQISV = E660LNV.SEQIPV) OR EXISTS (SELECT 1 FROM E140REN WHERE E140REN.CODEMP = {1} AND E140REN.CODFIL = {2} AND E140REN.CODEMP = E660LNV.CODEMP AND E140REN.CODFIL = E660LNV.CODFIL AND E140REN.CODSNF = E660LNV.CODSNF AND E140REN.NUMNFV = E660LNV.NUMNFI)) Banco de dados Sql Server DELETE FROM E660LNV FROM E660LNV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660LNV.CODEMP AND E140NFV.CODFIL = E660LNV.CODFIL AND E140NFV.CODSNF = E660LNV.CODSNF AND E140NFV.NUMNFV = E660LNV.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660LNV.CODEMP AND E660NFV.CODFIL = E660LNV.CODFIL AND E660NFV.CODSNF = E660LNV.CODSNF AND E660NFV.NUMNFI = E660LNV.NUMNFI AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 INNER JOIN ( SELECT CODEMP, CODFIL, CODSNF, NUMNFV, SEQIPV AS SEQITE FROM E140LPS WHERE CODEMP = {1} AND CODFIL = {2} UNION All SELECT CODEMP, CODFIL, CODSNF, NUMNFV, SEQIPV AS SEQITE FROM E140LNP WHERE CODEMP = {1} AND CODFIL = {2} UNION All SELECT CODEMP, CODFIL, CODSNF, NUMNFV, SEQISV AS SEQITE FROM E140LNS WHERE CODEMP = {1} AND CODFIL = {2} UNION All SELECT CODEMP, CODFIL, CODSNF, NUMNFV, 0 AS SEQITE FROM E140REN WHERE CODEMP = {1} AND CODFIL = {2} ) TABELA ON TABELA.CODEMP = E660LNV.CODEMP AND TABELA.CODFIL = E660LNV.CODFIL AND TABELA.CODSNF = E660LNV.CODSNF AND TABELA.NUMNFV = E660LNV.NUMNFI AND (TABELA.SEQITE = E660LNV.SEQIPV OR TABELA.SEQITE = 0) AND TABELA.CODEMP = E660NFV.CODEMP AND TABELA.CODFIL = E660NFV.CODFIL AND TABELA.CODSNF = E660NFV.CODSNF AND TABELA.NUMNFV = E660NFV.NUMNFI AND TABELA.CODEMP = E140NFV.CODEMP AND TABELA.CODFIL = E140NFV.CODFIL AND TABELA.CODSNF = E140NFV.CODSNF AND TABELA.NUMNFV = E140NFV.NUMNFV WHERE E660LNV.CODEMP = {1} AND E660LNV.CODFIL = {2}
VExcDgv Banco de dados Oracle DELETE FROM E660DGV WHERE E660DGV.CODEMP = {1} AND E660DGV.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = {1} AND E140NFV.CODFIL = {2} AND E140NFV.CODEMP = E660DGV.CODEMP AND E140NFV.CODFIL = E660DGV.CODFIL AND E140NFV.CODSNF = E660DGV.CODSNF AND E140NFV.NUMNFV = E660DGV.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = {1} AND E660NFV.CODFIL = {2} AND E660NFV.CODEMP = E660DGV.CODEMP AND E660NFV.CODFIL = E660DGV.CODFIL AND E660NFV.CODSNF = E660DGV.CODSNF AND E660NFV.NUMNFI = E660DGV.NUMNFI AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660DGV FROM E660DGV WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660DGV.CODEMP AND E140NFV.CODFIL = E660DGV.CODFIL AND E140NFV.CODSNF = E660DGV.CODSNF AND E140NFV.NUMNFV = E660DGV.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660DGV.CODEMP AND E660NFV.CODFIL = E660DGV.CODFIL AND E660NFV.CODSNF = E660DGV.CODSNF AND E660NFV.NUMNFI = E660DGV.NUMNFI AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 WHERE E660DGV.CODEMP = {1} AND E660DGV.CODFIL = {2}
xExcIDE

Banco de dados Oracle DELETE FROM E660IDE WHERE E660IDE.CODEMP = {1} AND E660IDE.CODFIL = {2} AND EXISTS (SELECT 1 FROM E140NFV WHERE E140NFV.CODEMP = E660IDE.CODEMP AND E140NFV.CODFIL = E660IDE.CODFIL AND E140NFV.CODSNF = E660IDE.CODSNF AND E140NFV.NUMNFV = E660IDE.NUMNFI) AND EXISTS (SELECT 1 FROM E660NFV WHERE E660NFV.CODEMP = E660IDE.CODEMP AND E660NFV.CODFIL = E660IDE.CODFIL AND E660NFV.CODSNF = E660IDE.CODSNF AND E660NFV.NUMNFI = E660IDE.NUMNFI AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0) Banco de dados Sql Server DELETE FROM E660IDE FROM E660IDE WITH (ROWLOCK) INNER JOIN E140NFV ON E140NFV.CODEMP = E660IDE.CODEMP AND E140NFV.CODFIL = E660IDE.CODFIL AND E140NFV.CODSNF = E660IDE.CODSNF AND E140NFV.NUMNFV = E660IDE.NUMNFI INNER JOIN E660NFV ON E660NFV.CODEMP = E660IDE.CODEMP AND E660NFV.CODFIL = E660IDE.CODFIL AND E660NFV.CODSNF = E660IDE.CODSNF AND E660NFV.NUMNFI = E660IDE.NUMNFI AND E660NFV.CODEMP = E140NFV.CODEMP AND E660NFV.CODFIL = E140NFV.CODFIL AND E660NFV.CODSNF = E140NFV.CODSNF AND E660NFV.NUMNFI = E140NFV.NUMNFV AND E660NFV.DATEMI >= {3,d} AND E660NFV.DATEMI <= {4,d} AND E660NFV.NUMLOT = 0 WHERE E660IDE.CODEMP = {1} AND E660IDE.CODFIL = {2}

Banco de dados Oracle

DELETE

FROM

E660NRC

WHERE

E660NRC.CODEMP = {CODEMP} AND

E660NRC.CODFIl = {CODFIl} AND

E660NRC.DATEMI >= {DATINI} AND

E660NRC.DATEMI <= {DATFIM} AND

(EXISTS(

SELECT

1

FROM

E440LPN LPN

WHERE

LPN.CODEMP = E660NRC.CODEMP AND

LPN.CODFIL = E660NRC.CODFIL AND

LPN.CODFOR = E660NRC.CODFOR AND

LPN.CODSNF = E660NRC.CODSNF AND

LPN.NUMNFC = E660NRC.NUMNFI) OR

EXISTS(

SELECT

1

FROM

E440LSN LSN

WHERE

LSN.CODEMP = E660NRC.CODEMP AND

LSN.CODFIL = E660NRC.CODFIL AND

LSN.CODFOR = E660NRC.CODFOR AND

LSN.CODSNF = E660NRC.CODSNF AND

LSN.NUMNFC = E660NRC.NUMNFI))

Banco de dados Sql Server

DELETE FROM E660NRC

FROM E660NRC WITH (ROWLOCK)

INNER JOIN E440NFC ON E440NFC.CODEMP = E660NRC.CODEMP AND

E440NFC.CODFIL = E660NRC.CODFIL AND

E440NFC.CODFOR = E660NRC.CODFOR AND

E440NFC.CODSNF = E660NRC.CODSNF AND

E440NFC.NUMNFC = E660NRC.NUMNFI

INNER JOIN E660NFC ON E660NFC.CODEMP = E660NRC.CODEMP AND

E660NFC.CODFIL = E660NRC.CODFIL AND

E660NFC.CODFOR = E660NRC.CODFOR AND

E660NFC.CODSNF = E660NRC.CODSNF AND

E660NFC.NUMNFI = E660NRC.NUMNFI AND

E660NFC.CODEMP = E440NFC.CODEMP AND

E660NFC.CODFIL = E440NFC.CODFIL AND

E660NFC.CODFOR = E440NFC.CODFOR AND

E660NFC.CODSNF = E440NFC.CODSNF AND

E660NFC.NUMNFI = E440NFC.NUMNFC AND

E660NFC.DATENT >= {DATINI} AND

E660NFC.DATENT <= {DATFIM} AND

E660NFC.NUMLOT = 0

INNER JOIN (

SELECT CODEMP, CODFIL, CODFOR, CODSNF, NUMNFC

FROM E440LPN

WHERE CODEMP = {CODEMP} AND

CODFIL = {CODFIl}

UNION ALL

SELECT CODEMP, CODFIL, CODFOR, CODSNF, NUMNFC

FROM E440LSN

WHERE CODEMP = {CODEMP} AND

CODFIL = {CODFIl}

) TABELA ON TABELA.CODEMP = E660NRC.CODEMP AND

TABELA.CODFIL = E660NRC.CODFIL AND

TABELA.CODFOR = E660NRC.CODFOR AND

TABELA.CODSNF = E660NRC.CODSNF AND

TABELA.NUMNFC = E660NRC.NUMNFI AND

TABELA.CODEMP = E660NFC.CODEMP AND

TABELA.CODFIL = E660NFC.CODFIL AND

TABELA.CODFOR = E660NFC.CODFOR AND

TABELA.CODSNF = E660NFC.CODSNF AND

TABELA.NUMNFC = E660NFC.NUMNFI AND

TABELA.CODEMP = E440NFC.CODEMP AND

TABELA.CODFIL = E440NFC.CODFIL AND

TABELA.CODFOR = E440NFC.CODFOR AND

TABELA.CODSNF = E440NFC.CODSNF AND

TABELA.NUMNFC = E440NFC.NUMNFC

WHERE E660NRC.CODEMP = {CODEMP} AND

E660NRC.CODFIL = {CODFIl}

IMPAExcDPR Banco de dados Oracle DELETE FROM E660DPR WHERE E660DPR.CODEMP = {1} AND E660DPR.CODFIL = {2} AND EXISTS (SELECT 1 FROM E440NFC WHERE E440NFC.CODEMP = E660DPR.CODEMP AND E440NFC.CODFIL = E660DPR.CODFIL AND E440NFC.CODFOR = E660DPR.CODFOR AND E440NFC.NUMNFC = E660DPR.NUMNFI AND E440NFC.CODSNF = E660DPR.CODSNF) AND EXISTS (SELECT 1 FROM E660NFC WHERE E660NFC.CODEMP = E660DPR.CODEMP AND E660NFC.CODFIL = E660DPR.CODFIL AND E660NFC.CODFOR = E660DPR.CODFOR AND E660NFC.NUMNFI = E660DPR.NUMNFI AND E660NFC.CODSNF = E660DPR.CODSNF AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d}) AND EXISTS (SELECT 1 FROM E440DPR WHERE E440DPR.CODEMP = E660DPR.CODEMP AND E440DPR.CODFIL = E660DPR.CODFIL AND E440DPR.CODFOR = E660DPR.CODFOR AND E440DPR.NUMNFC = E660DPR.NUMNFI AND E440DPR.CODSNF = E660DPR.CODSNF) Banco de dados Sql Server DELETE FROM E660DPR FROM E660DPR WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660DPR.CODEMP AND E440NFC.CODFIL = E660DPR.CODFIL AND E440NFC.CODFOR = E660DPR.CODFOR AND E440NFC.CODSNF = E660DPR.CODSNF AND E440NFC.NUMNFC = E660DPR.NUMNFI INNER JOIN E660NFC ON E660NFC.CODEMP = E660DPR.CODEMP AND E660NFC.CODFIL = E660DPR.CODFIL AND E660NFC.CODFOR = E660DPR.CODFOR AND E660NFC.CODSNF = E660DPR.CODSNF AND E660NFC.NUMNFI = E660DPR.NUMNFI AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 INNER JOIN E440DPR ON E440DPR.CODEMP = E660DPR.CODEMP AND E440DPR.CODFIL = E660DPR.CODFIL AND E440DPR.CODFOR = E660DPR.CODFOR AND E440DPR.CODSNF = E660DPR.CODSNF AND E440DPR.NUMNFC = E660DPR.NUMNFI AND E440DPR.CODEMP = E660NFC.CODEMP AND E440DPR.CODFIL = E660NFC.CODFIL AND E440DPR.CODFOR = E660NFC.CODFOR AND E440DPR.CODSNF = E660NFC.CODSNF AND E440DPR.NUMNFC = E660NFC.NUMNFI AND E440DPR.CODEMP = E440NFC.CODEMP AND E440DPR.CODFIL = E440NFC.CODFIL AND E440DPR.CODFOR = E440NFC.CODFOR AND E440DPR.CODSNF = E440NFC.CODSNF AND E440DPR.NUMNFC = E440NFC.NUMNFC WHERE E660DPR.CODEMP = {1} AND E660DPR.CODFIL = {2}
VExcExf Banco de dados Oracle DELETE FROM E660EXF WHERE E660EXF.CODEMP = {1} AND E660EXF.CODFIL = {2} AND EXISTS ( SELECT 1 FROM E440EXF, E440NFC WHERE E440EXF.CODEMP = E440NFC.CODEMP AND E440EXF.CODFIL = E440NFC.CODFIL AND E440EXF.CODFOR = E440NFC.CODFOR AND E440EXF.NUMNFC = E440NFC.NUMNFC AND E440EXF.CODSNF = E440NFC.CODSNF AND E440EXF.CODEMP = {1} AND E440EXF.CODFIL = {2} AND E440NFC.DATENT >= {3,d} AND E440NFC.DATENT <= {4,d} AND E440EXF.CODEMP = E660EXF.CODEMP AND E440EXF.CODFIL = E660EXF.CODFIL AND E440EXF.CODFOR = E660EXF.CODFOR AND E440EXF.CODSNF = E660EXF.CODSNF AND E440EXF.NUMNFC = E660EXF.NUMNFI AND E440EXF.SEQEXF = E660EXF.SEQEXF) Banco de dados Sql Server DELETE FROM E660EXF FROM E660EXF WITH (ROWLOCK) INNER JOIN E440NFC ON E440NFC.CODEMP = E660EXF.CODEMP AND E440NFC.CODFIL = E660EXF.CODFIL AND E440NFC.CODFOR = E660EXF.CODFOR AND E440NFC.CODSNF = E660EXF.CODSNF AND E440NFC.NUMNFC = E660EXF.NUMNFI INNER JOIN E660NFC ON E660NFC.CODEMP = E660EXF.CODEMP AND E660NFC.CODFIL = E660EXF.CODFIL AND E660NFC.CODFOR = E660EXF.CODFOR AND E660NFC.CODSNF = E660EXF.CODSNF AND E660NFC.NUMNFI = E660EXF.NUMNFI AND E660NFC.CODEMP = E440NFC.CODEMP AND E660NFC.CODFIL = E440NFC.CODFIL AND E660NFC.CODFOR = E440NFC.CODFOR AND E660NFC.CODSNF = E440NFC.CODSNF AND E660NFC.NUMNFI = E440NFC.NUMNFC AND E660NFC.DATENT >= {3,d} AND E660NFC.DATENT <= {4,d} AND E660NFC.NUMLOT = 0 INNER JOIN E440EXF ON E440EXF.CODEMP = E660EXF.CODEMP AND E440EXF.CODFIL = E660EXF.CODFIL AND E440EXF.CODFOR = E660EXF.CODFOR AND E440EXF.CODSNF = E660EXF.CODSNF AND E440EXF.NUMNFC = E660EXF.NUMNFI AND E440EXF.SEQEXF = E660EXF.SEQEXF AND E440EXF.CODEMP = E660NFC.CODEMP AND E440EXF.CODFIL = E660NFC.CODFIL AND E440EXF.CODFOR = E660NFC.CODFOR AND E440EXF.CODSNF = E660NFC.CODSNF AND E440EXF.NUMNFC = E660NFC.NUMNFI AND E440EXF.CODEMP = E440NFC.CODEMP AND E440EXF.CODFIL = E440NFC.CODFIL AND E440EXF.CODFOR = E440NFC.CODFOR AND E440EXF.CODSNF = E440NFC.CODSNF AND E440EXF.NUMNFC = E440NFC.NUMNFC WHERE E660EXF.CODEMP = {1} AND E660EXF.CODFIL = {2}
VAtuEnt UPDATE E440NFC SET INTIMP = 'S' WHERE CODEMP = :CODEMP AND CODFIL = :CODFIL AND NUMNFC = :NUMNFC AND CODFOR = :CODFOR AND CODSNF = :CODSNF AND INTIMP <> 'S' Variável VMovExp: SELECT * FROM E145EBQ WHERE E145EBQ.CODEMP = {CODEMP} AND E145EBQ.CODFIL = {CODFIL} AND ((E145EBQ.DATAVB >= {DATINI} AND E145EBQ.DATAVB <= {DATFIM} AND E145EBQ.SITEBQ = ''2'') OR ((E145EBQ.DATAVB IS NULL OR E145EBQ.DATAVB = {DATZER}) AND E145EBQ.SITEBQ = ''1'')) AND E145EBQ.TIPEBQ = ''E''
VPctRtc SELECT SUM(VLRCTA) AS VLRCTA
FROM (SELECT DISTINCT RAT.NUMPRJ,RAT.CODFPJ,RAT.CTAFIN,RAT.CTARED,RAT.VLRCTA,RAT.SEQIPC,RAT.SEQISC
FROM E440RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.CODFOR = {CODFOR}
AND RAT.NUMNFC = {NUMNFC}
AND RAT.CODSNF = {CODSNF}
AND RAT.CTARED = {CTARED}) RATEIO
VTctRtc SELECT SUM(VLRCTA) AS TOTVLR
FROM (SELECT DISTINCT RAT.NUMPRJ,RAT.CODFPJ,RAT.CTAFIN,RAT.CTARED,RAT.VLRCTA,RAT.SEQIPC,RAT.SEQISC
FROM E440RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.CODFOR = {CODFOR}
AND RAT.NUMNFC = {NUMNFC}
AND RAT.CODSNF = {CODSNF} ) RATEIO
VPctRtv SELECT SUM(VLRCTA) AS VLRCTA
FROM (SELECT DISTINCT RAT.NUMPRJ,RAT.CODFPJ,RAT.CTAFIN,RAT.CTARED,RAT.VLRCTA,RAT.SEQIPV,RAT.SEQISV
FROM E140RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.NUMNFV = {NUMNFV}
AND RAT.CODSNF = {CODSNF}
AND RAT.CTARED = {CTARED} ) RATEIO
VTctRtv SELECT SUM(VLRCTA) AS VLRCTA
FROM (SELECT DISTINCT RAT.NUMPRJ,RAT.CODFPJ,RAT.CTAFIN,RAT.CTARED,RAT.VLRCTA,RAT.SEQIPV,RAT.SEQISV
FROM E140RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.NUMNFV = {NUMNFV}
AND RAT.CODSNF = {CODSNF} ) RATEIO
VPrtRtc SELECT SUM(RAT.VLRRAT) AS VLRRAT
FROM E440RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.CODFOR = {CODFOR}
AND RAT.CODSNF = {CODSNF}
AND RAT.NUMNFC = {NUMNFC}
AND RAT.CTARED = {CTARED}
AND RAT.CODCCU = {CODCCU}
VTrtRtc SELECT SUM(RAT.VLRRAT) AS VLRRAT
FROM E440RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.CODFOR = {CODFOR}
AND RAT.CODSNF = {CODSNF}
AND RAT.NUMNFC = {NUMNFC}
AND RAT.CTARED = {CTARED}
VPrtRtv SELECT SUM(RAT.VLRRAT) AS VLRRAT
FROM E140RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.CODSNF = {CODSNF}
AND RAT.NUMNFV = {NUMNFV}
AND RAT.CTARED = {CTARED}
AND RAT.CODCCU = {CODCCU}
VTrtRtv SELECT SUM(RAT.VLRRAT) AS VLRRAT
FROM E140RAT RAT
WHERE RAT.CODEMP = {CODEMP}
AND RAT.CODFIL = {CODFIL}
AND RAT.CODSNF = {CODSNF}
AND RAT.NUMNFV = {NUMNFV}
AND RAT.CTARED = {CTARED}
VMovExp SELECT E145EBQ.CODEMP,E145EBQ.CODFIL,E145EBQ.NUMEBQ,E145EBQ.CODTRA,
E145EBQ.PLAVEI,E145EBQ.NOMMOT,E145EBQ.DOCMOT,E145EBQ.FONEBQ,
E145EBQ.DSNEBQ,E145EBQ.OBSEBQ,E145EBQ.DATSAI,E145EBQ.HORSAI,
E145EBQ.USUGER,E145EBQ.DATGER,E145EBQ.HORGER,E145EBQ.CODMTR,
E145EBQ.SITEBQ,E145EBQ.DATFEC,E145EBQ.HORFEC,E145EBQ.TIPEBQ,
E145EBQ.DOCEXP,E145EBQ.NUMDEC,E145EBQ.DATDEC,E145EBQ.NATEXP,
E145EBQ.NUMEXP,E145EBQ.DATEXP,E145EBQ.CHCEBQ,E145EBQ.DATCHC,
E145EBQ.DATAVB,E145EBQ.TIPCHC,E145EBQ.CODPAI,E145EBQ.INTIMP
FROM E145EBQ
WHERE E145EBQ.CODEMP = {CODEMP} AND
E145EBQ.CODFIL = {CODFIL} AND
E145EBQ.DATAVB >= {DATINI} AND
E145EBQ.DATAVB <= {DATFIM} AND
E145EBQ.SITEBQ = '2' AND
E145EBQ.TIPEBQ = 'E'
VDocNfx SELECT E145NFV.CODEMP,E145NFV.CODFIL,E145NFV.NUMEBQ, E145NFV.SEQEBQ,E145NFV.FILNFV,E145NFV.SNFNFV,E145NFV.NUMNFV FROM E145NFV WHERE CODEMP = {CODEMP} AND CODFIL = {CODFIL} AND NUMEBQ = {NUMEBQ} ORDER BY SEQEBQ
VExcExp DELETE
FROM E660EXP
WHERE E660EXP.CODEMP = {1} AND
E660EXP.CODFIL = {2} AND
((E660EXP.DATAVB >= {3,d} AND
E660EXP.DATAVB <= {4,d}) OR
(E660EXP.DATAVB OR E660EXP.DATAVB = {5,d})) AND
EXISTS (SELECT 1
FROM E145EBQ
WHERE E145EBQ.CODEMP = {1} AND
E145EBQ.CODFIL = {2} AND
E145EBQ.NUMEBQ = E660EXP.NUMEBQ)
VExcNfx DELETE
FROM E660NFX
WHERE E660NFX.CODEMP = {1} AND
E660NFX.CODFIL = {2} AND
EXISTS (SELECT 1
FROM E660EXP
WHERE E660EXP.CODEMP = {1} AND
E660EXP.CODFIL = {2} AND
E660EXP.NUMEBQ = E660NFX.NUMEBQ AND
((E660EXP.DATAVB >= {3,d} AND E660EXP.DATAVB <= {4,d})
(E660EXP.DATAVB IS NULL OR E660EXP.DATAVB = {5,D}))) AND
EXISTS (SELECT 1
FROM E145EBQ
WHERE E145EBQ.CODEMP = {1} AND
E145EBQ.CODFIL = {2} AND
E145EBQ.NUMEBQ = E660NFX.NUMEBQ AND
((E145EBQ.DATAVB >= {3,d} AND E145EBQ.DATAVB <= {4,d})
(E145EBQ.DATAVB IS NULL OR E145EBQ.DATAVB = {5,D}))) AND
EXISTS (SELECT 1
FROM E145NFV
WHERE E145NFV.CODEMP = {1} AND
E145NFV.CODFIL = {2} AND
E145NFV.NUMEBQ = E660NFX.NUMEBQ AND
E145NFV.SEQEBQ = E660NFX.SEQEBQ)
VAtuExp UPDATE E145EBQ
SET INTIMP = 'S'
WHERE CODEMP = {1} AND
CODFIL = {2} AND
NUMEBQ = {3}
VRelEnt SELECT *
FROM E440EXF
WHERE E440EXF.CODEMP = {CODEMP} AND
E440EXF.CODFIL = {CODFIL} AND
E440EXF.CODFOR = {CODFOR} AND
E440EXF.NUMNFC = {NUMNFC} AND
E440EXF.CODSNF = {CODSNF}
GerNotaTipo5

SELECT LPN.CODEMP, LPN.CODFIL, LPN.CODFOR, LPN.CODSNF, LPN.NUMNFC AS NUMNFI, 0 AS SEQNFR, 1 AS OPENFR,

0 AS EMINFR, IDE.CHVDOE AS CHVNEL, 0 AS TIPPAR, NFV.CODCLI AS CODPAR, NFV.CODEDC, SNF.CODSEL,

SNF.CODSSL, LPN.NFVRLC AS NUMNFR, NFV.DATEMI

FROM E440LPN LPN

INNER JOIN E140NFV NFV ON NFV.CODEMP = LPN.EMPRLC AND

NFV.CODFIL = LPN.FILRLC AND

NFV.NUMNFV = LPN.NFVRLC AND

NFV.CODSNF = LPN.SNFRLC

INNER JOIN E140IDE IDE ON IDE.CODEMP = LPN.EMPRLC AND

IDE.CODFIL = LPN.FILRLC AND

IDE.NUMNFV = LPN.NFVRLC AND

IDE.CODSNF = LPN.SNFRLC AND

IDE.CODEMP = NFV.CODEMP AND

IDE.CODFIL = NFV.CODFIL AND

IDE.NUMNFV = NFV.NUMNFV AND

IDE.CODSNF = NFV.CODSNF

INNER JOIN E020SNF SNF ON SNF.CODEMP = LPN.EMPRLC AND

SNF.CODFIL = LPN.FILRLC AND

SNF.CODSNF = LPN.SNFRLC AND

SNF.CODEMP = NFV.CODEMP AND

SNF.CODFIL = NFV.CODFIL AND

SNF.CODSNF = NFV.CODSNF AND

SNF.CODEMP = IDE.CODEMP AND

SNF.CODFIL = IDE.CODFIL AND

SNF.CODSNF = IDE.CODSNF

WHERE LPN.CODEMP = {CODEMP} AND

LPN.CODFIL = {CODFIL} AND

LPN.CODFOR = {CODFOR} AND

LPN.CODSNF = {CODSNF} AND

LPN.NUMNFC = {NUMNFC}

GROUP BY LPN.CODEMP, LPN.CODFIL, LPN.CODFOR, LPN.CODSNF, LPN.NUMNFC, IDE.CHVDOE, NFV.CODCLI, NFV.CODEDC,

SNF.CODSEL, SNF.CODSSL ,LPN.NFVRLC, NFV.DATEMI

UNION

SELECT LSN.CODEMP, LSN.CODFIL, LSN.CODFOR, LSN.CODSNF, LSN.NUMNFC AS NUMNFI, 0 AS SEQNFR, 1 AS OPENFR,

0 AS EMINFR, IDE.CHVDOE AS CHVNEL, 0 AS TIPPAR, NFV.CODCLI AS CODPAR, NFV.CODEDC, SNF.CODSEL,

SNF.CODSSL,LSN.NFVRLC AS NUMNFR, NFV.DATEMI

FROM E440LSN LSN

INNER JOIN E140NFV NFV ON NFV.CODEMP = LSN.EMPRLC AND

NFV.CODFIL = LSN.FILRLC AND

NFV.NUMNFV = LSN.NFVRLC AND

NFV.CODSNF = LSN.SNFRLC

INNER JOIN E140IDE IDE ON IDE.CODEMP = LSN.EMPRLC AND

IDE.CODFIL = LSN.FILRLC AND

IDE.NUMNFV = LSN.NFVRLC AND

IDE.CODSNF = LSN.SNFRLC AND

IDE.CODEMP = NFV.CODEMP AND

IDE.CODFIL = NFV.CODFIL AND

IDE.NUMNFV = NFV.NUMNFV AND

IDE.CODSNF = NFV.CODSNF

INNER JOIN E020SNF SNF ON SNF.CODEMP = LSN.EMPRLC AND

SNF.CODFIL = LSN.FILRLC AND

SNF.CODSNF = LSN.SNFRLC AND

SNF.CODEMP = NFV.CODEMP AND

SNF.CODFIL = NFV.CODFIL AND

SNF.CODSNF = NFV.CODSNF AND

SNF.CODEMP = IDE.CODEMP AND

SNF.CODFIL = IDE.CODFIL AND

SNF.CODSNF = IDE.CODSNF

WHERE LSN.CODEMP = {CODEMP} AND

LSN.CODFIL = {CODFIL} AND

LSN.CODFOR = {CODFOR} AND

LSN.CODSNF = {CODSNF} AND

LSN.NUMNFC = {NUMNFC}

GROUP BY LSN.CODEMP, LSN.CODFIL, LSN.CODFOR, LSN.CODSNF, LSN.NUMNFC, IDE.CHVDOE, NFV.CODCLI, NFV.CODEDC,

SNF.CODSEL, SNF.CODSSL, LSN.NFVRLC, NFV.DATEMI

ExcNotaTipo5

DELETE
FROM
E660NRC
WHERE
E660NRC.CODEMP = {CODEMP} AND
E660NRC.CODFIl = {CODFIl} AND
E660NRC.DATEMI >= {DATINI} AND
E660NRC.DATEMI <= {DATFIM} AND
(EXISTS(
SELECT
1
FROM
E440LPN LPN
WHERE
LPN.CODEMP = E660NRC.CODEMP AND
LPN.CODFIL = E660NRC.CODFIL AND
LPN.CODFOR = E660NRC.CODFOR AND
LPN.CODSNF = E660NRC.CODSNF AND
LPN.NUMNFC = E660NRC.NUMNFI) OR
EXISTS(
SELECT
1
FROM
E440LSN LSN
WHERE
LSN.CODEMP = E660NRC.CODEMP AND
LSN.CODFIL = E660NRC.CODFIL AND
LSN.CODFOR = E660NRC.CODFOR AND
LSN.CODSNF = E660NRC.CODSNF AND
LSN.NUMNFC = E660NRC.NUMNFI))

Este artigo ajudou você?