select distinct di.idlaf,di.numitem,dic.natrec from dlaf dl
inner join ditem di on (di.idlaf = dl.idlaf)
left join ditemcompl dic on (dic.idlaf = di.idlaf and di.numitem = dic.numitem)
inner join tprd tp on (tp.idprd = di.idprd)
inner join dtrbitem dti on (dti.idlaf = di.idlaf and dti.numitem = di.numitem)
where tp.descricao like '%arroz%' and dl.tipolf = 'S'
and dl.dataemissao >= '2011/08/01' and dl.dataemissao <= '2011/08/31'
and dti.sittributaria in ('04','06') and dl.seriedoc in ('1','ECF')
and dic.natrec is null
order by di.idlaf
Preciso atualizar o campo dic.natrec desses 353 registros. Fiz assim:
update ditemcompl set natrec = '105'
from dlaf dl inner join ditem di on (dl.idlaf = di.idlaf)
left join ditemcompl dic on (dic.idlaf = di.idlaf and dic.numitem = di.numitem)
inner join tprd tp on (tp.idprd = di.idprd)
inner join dtrbitem dti on (dti.idlaf = di.idlaf and dti.numitem = di.numitem)
where tp.descricao like '%arroz%' and dl.tipolf = 'S'
and dl.dataemissao >= '2011/08/01' and dl.dataemissao <= '2011/08/31'
and dti.sittributaria in ('04','06')
and dl.seriedoc in ('1','ECF') and dic.natrec is null
Atualizou apenas 196 registros. Ou seja como se a query buscasse apenas os idlaf (identificador do lanc. fiscal) sem o numitem que seriam os items do lançamento fiscal (totalizando 353 registros).
A forma como estou aplicando o update deve estar incorreta.
Question
ROMANVPP
Boa tarde pessoal,
Tenho essa consulta que me retorna 353 registros:
select distinct di.idlaf,di.numitem,dic.natrec from dlaf dl
inner join ditem di on (di.idlaf = dl.idlaf)
left join ditemcompl dic on (dic.idlaf = di.idlaf and di.numitem = dic.numitem)
inner join tprd tp on (tp.idprd = di.idprd)
inner join dtrbitem dti on (dti.idlaf = di.idlaf and dti.numitem = di.numitem)
where tp.descricao like '%arroz%' and dl.tipolf = 'S'
and dl.dataemissao >= '2011/08/01' and dl.dataemissao <= '2011/08/31'
and dti.sittributaria in ('04','06') and dl.seriedoc in ('1','ECF')
and dic.natrec is null
order by di.idlaf
Preciso atualizar o campo dic.natrec desses 353 registros. Fiz assim:
update ditemcompl set natrec = '105'
from dlaf dl inner join ditem di on (dl.idlaf = di.idlaf)
left join ditemcompl dic on (dic.idlaf = di.idlaf and dic.numitem = di.numitem)
inner join tprd tp on (tp.idprd = di.idprd)
inner join dtrbitem dti on (dti.idlaf = di.idlaf and dti.numitem = di.numitem)
where tp.descricao like '%arroz%' and dl.tipolf = 'S'
and dl.dataemissao >= '2011/08/01' and dl.dataemissao <= '2011/08/31'
and dti.sittributaria in ('04','06')
and dl.seriedoc in ('1','ECF') and dic.natrec is null
Atualizou apenas 196 registros. Ou seja como se a query buscasse apenas os idlaf (identificador do lanc. fiscal) sem o numitem que seriam os items do lançamento fiscal (totalizando 353 registros).
A forma como estou aplicando o update deve estar incorreta.
Se puderem dar uma força eu agradeço.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.