Han Brinkman
2nd July 2004, 11:23
I have to develop a report that has to reconcile finance transactions. A first select selects a part of the records. After that I have to make a selection again on the table but without the records from the first selection.
I did use a 'not exists' for that. However the not exists acts very weird. Here is the select that I use:
|* Manual transactions
select tfgld106.*
where tfgld106.leac = "099500 "
and ((tfgld106.fyer = :fyer.f and tfgld106.fprd >= :fper.f)
or tfgld106.fyer > :fyer.f)
and ((tfgld106.fyer = :fyer.t and tfgld106.fprd <= :fper.t)
or tfgld106.fyer < :fyer.t)
and tfgld106.dim5 <> "RECONCILED"
and tfgld106.otyp <> "230"
and tfgld106.otyp <> "221"
and not exists (
select tfgld106sp.*
from tdsls401, cisli245, tfgld418, tfgld106 tfgld106sp
where tfgld106sp.leac = "099500 "
and tdsls401._index1 between { :orno.f } and { :orno.t }
and tdsls401.citg between :citg.f and :citg.t
and ((tfgld106sp.fyer = :fyer.f and tfgld106sp.fprd >= :fper.f)
or tfgld106sp.fyer > :fyer.f)
and ((tfgld106sp.fyer = :fyer.t and tfgld106sp.fprd <= :fper.t)
or tfgld106sp.fyer < :fyer.t)
and cisli245._index3 = { cisli.stat.posted, :curr.comp,
cisli.ortp.sales, tdsls401.orno, tdsls401.pono,
tdsls401.sqnb, tdsls401.shpm }
and tfgld418._index2 = { :curr.comp, tdsls401.cprj,
tctror.sli.sales, tdsls401.orno, tdsls401.pono }
and tfgld418.sint = tfgld.sint.posted
and tfgld418.frot = tcfin.frto.to
and tfgld106sp.otyp = tfgld418.ttyp
and tfgld106sp.odoc = tfgld418.docn
and tfgld106sp.olin = tfgld418.lino
and tfgld106sp.dim5 <> "RECONCILED"
and tdsls401.dqua > 0
and tfgld106sp.otyp <> "230"
and tfgld106sp.otyp <> "221"
)
If it don't include the where clause otype <> "230" and otyp <> "221" in both select parts it doesn't find anything!
Anyone has an idea what I am doing wrong?
I did use a 'not exists' for that. However the not exists acts very weird. Here is the select that I use:
|* Manual transactions
select tfgld106.*
where tfgld106.leac = "099500 "
and ((tfgld106.fyer = :fyer.f and tfgld106.fprd >= :fper.f)
or tfgld106.fyer > :fyer.f)
and ((tfgld106.fyer = :fyer.t and tfgld106.fprd <= :fper.t)
or tfgld106.fyer < :fyer.t)
and tfgld106.dim5 <> "RECONCILED"
and tfgld106.otyp <> "230"
and tfgld106.otyp <> "221"
and not exists (
select tfgld106sp.*
from tdsls401, cisli245, tfgld418, tfgld106 tfgld106sp
where tfgld106sp.leac = "099500 "
and tdsls401._index1 between { :orno.f } and { :orno.t }
and tdsls401.citg between :citg.f and :citg.t
and ((tfgld106sp.fyer = :fyer.f and tfgld106sp.fprd >= :fper.f)
or tfgld106sp.fyer > :fyer.f)
and ((tfgld106sp.fyer = :fyer.t and tfgld106sp.fprd <= :fper.t)
or tfgld106sp.fyer < :fyer.t)
and cisli245._index3 = { cisli.stat.posted, :curr.comp,
cisli.ortp.sales, tdsls401.orno, tdsls401.pono,
tdsls401.sqnb, tdsls401.shpm }
and tfgld418._index2 = { :curr.comp, tdsls401.cprj,
tctror.sli.sales, tdsls401.orno, tdsls401.pono }
and tfgld418.sint = tfgld.sint.posted
and tfgld418.frot = tcfin.frto.to
and tfgld106sp.otyp = tfgld418.ttyp
and tfgld106sp.odoc = tfgld418.docn
and tfgld106sp.olin = tfgld418.lino
and tfgld106sp.dim5 <> "RECONCILED"
and tdsls401.dqua > 0
and tfgld106sp.otyp <> "230"
and tfgld106sp.otyp <> "221"
)
If it don't include the where clause otype <> "230" and otyp <> "221" in both select parts it doesn't find anything!
Anyone has an idea what I am doing wrong?