kondratus
14th February 2004, 09:45
Hello,
I have following query, he finds several records , but if delete the commentary that I get 'No rows selected'. Where problem?

select ticst001.pdno, ticst001.pono,
min(tisfc010.opno):min_opno,tisfc010.tano
from tiitm001, ticst001, tisfc001, tirou001, tisfc010
where tiitm001.kitm =1
and ticst001.qucs = 0
and tisfc001.osta > 1 and tisfc001.osta < 6
and tisfc001.pdno between :pdno.f and :pdno.t
and tisfc010.qrjc = 0
and tisfc010.qcmp = 0
and tiitm001.item = ticst001.sitm
and ticst001.pdno = tisfc001.pdno
and ticst001.pdno = tisfc010.pdno
and ticst001.cwar = tirou001.wipw
and tirou001.cwoc = tisfc010.cwoc
and ticst001.opno = 0
and(
(tiitm001.dsca like ".*aaaaaa.*" and tisfc010.tano = 2525 )
| or
| (tiitm001.dsca like ".*bbbbbb.*" and tisfc010.tano = 2519)
)
group by ticst001.pdno, ticst001.pono, tisfc010.tano

gfasbender
14th February 2004, 16:07
If you use the groupby statement, you're not really selecting a ticst001 record. In your selectdo I would call your own delete function and pass the ticst001 key.


selectdo
del_ticst001(ticst001.pdno, ticst001.pono, ticst001.tano)
endselect

...

function del_ticst001(domain tipdno pdno, domain tipono pono, domain titano tano)
{
select ticst001.*
from ticst001
where ticst001._index1 = {:pdno, :pono, :tano}
selectdo
db.retry.point()
db.delete(ticst001, db.retry)
commit.transaction()
endselect
}

kondratus
16th February 2004, 09:03
Hi gfasbender!
Excuse for my English, but you have not correctly understood me, I wanted to tell, that it is necessary to remove comments from query, that is in the simplified variant the following searches should turn out:

select tiitm001.*, tisfc010.*
from tiitm001, tisfc010
where tiitm001.kitm =1
and(
(tiitm001.dsca like ".*aaaaaa.*" and tisfc010.tano = 2525 )
| or
| (tiitm001.dsca like ".*bbbbbb.*" and tisfc010.tano = 2519)
)
This query returns some recordings but if we shall make so:

select tiitm001.*, tisfc010.*
from tiitm001, tisfc010
where tiitm001.kitm =1
and(
(tiitm001.dsca like ".*aaaaaa.*" and tisfc010.tano = 2525 )
or
(tiitm001.dsca like ".*bbbbbb.*" and tisfc010.tano = 2519)
)
The query returns that that is found nothing.

Martin
16th February 2004, 09:34
@kondratus

its very tricky to combine an 'and' condition and two 'or' conditions.
The result is not really clear.
So the better way is the follwowing:

select tiitm001.*, tisfc010.*
from tiitm001, tisfc010
where (tiitm001.kitm =1
and
tiitm001.dsca like ".*aaaaaa.*" and tisfc010.tano = 2525 )
or
(tiitm001.kitm=1 and
tiitm001.dsca like ".*bbbbbb.*" and tisfc010.tano = 2519)


Martin