• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Find Is Reverse Query

Stefan

Active Member
#6
Please provide a complete example, with a complete piece of code and a complete definition instead of feeding half words.
 
#7
Code:
FIND LAST req_mov
    WHERE req_mov.req = 7203574  NO-LOCK NO-ERROR.


            DISP req_mov.seq.
Code:
Table: req_mov

Flags Index Name              St Area Cnt Field Name
----- ----------------------- ------- --- ----------------------
      index_req_mov_1         8         1 + req

      index_req_mov_2         8         1 + sequencia

      index_req_mov_3         8         2 + req
                                          + situacao

      Index_req_mov_4         8         3 + req
                                          + situacao
                                          + data

      index_req_mov_5         8         2 + situacao
                                          + data

      index_req_mov_6         8         2 + cod_usuario
                                          + data

pu    pk_req_mov              8         2 + sequencia
                                          + req
 

Stefan

Active Member
#8
So why do you think seq 1 or 2 should be shown when you perform a find last on req? The whole problem with find first and last is - what is first and what is last. If you had an index with components req and seq then a find last would (probably) return what you are expecting. Since you do not have that index you will need to use a query and specify the order which you find interesting:

Code:
for each req_mov
   where req_mov.req = #
by req_mov.req 
by req_mov.seq descending
while iseq = ?
:
   iseq = req_mov.seq.
end.
display req_mov.seq
Also do not get yourself tricked into replacing the above for each with a for first - I'm pretty sure it won't do what you expect.