django25
19th March 2009, 14:03
Sir
There is one script

select tccom012.*
from tccom012
where tccom012.cuno between :cuno.f and :cuno.t
selectdo
endselect

In input we give cuno as zz010.
In table tccom012 there are 3 records for zz010. The index is defined on TCCOM012.CUNO & TCCOM012.CCOR (postal address).
The first 2 records have same data except postal address are 201 & 301 respectively.
The third record for zz010, has different data & different postal address(401).
In the input we give only the CUNO – zz010. The output report gives the data contained in the third record(postal address – 401).

1, why does it pick from the last record & not from first.

We want the data to be picked from first record.
We may have to give the postal address as input . But it will be difficult to remember postal address.
Is there any other way.

Regards
Django

vahdani
19th March 2009, 15:24
Hi Django,

the select statement brings all 3 records one after the other. You cann access each record in between selectdo and endselect statements. after endselect you see only the last record selected. Use one of the followng codes to get only the first record after endselect.


select tccom012.*
from tccom012
where tccom012.cuno between :cuno.f and :cuno.t
order by tccom012.ccor
as set with 1 rows
selectdo
endselect

or following:


select tccom012.*
from tccom012
where tccom012.cuno between :cuno.f and :cuno.t
order by tccom012.ccor
selectdo
break
endselect

django25
20th March 2009, 06:23
Thanks for the help Sir