Last Record 
Author Message
 Last Record

Quote:

>Anybody know of any code that will quickly find the last record in a
>field, I have a table with 10,000 records and the first three fields
>are keyed.  I need some code that will locate the first record with
>the required value in the first keyed field and then QUICKLY find the
>last record with the same value in the same keyed field..

>This is for Pdox4.0DOS

>I could use a Locate Next in a While loop until retval is false, but
>thats a bit sluggish..

Unfortunately, I think that is the only way you can do it in Paradox for DOS.

If the "INDEX" command had a "descending" keyword (i.e. INDEX maintained "MyTable"
on "First Key" Descending) it would be a piece of cake, but it doesn't.  <sigh>

Anyone else have a suggestion?

Jim



Wed, 01 Jul 1998 03:00:00 GMT
 Last Record

Anybody know of any code that will quickly find the last record in a
field, I have a table with 10,000 records and the first three fields
are keyed.  I need some code that will locate the first record with
the required value in the first keyed field and then QUICKLY find the
last record with the same value in the same keyed field..

This is for Pdox4.0DOS

I could use a Locate Next in a While loop until retval is false, but
thats a bit sluggish..

Any Ideas ???

Gary S.
**

PC Specialist
BASF Coatings + Inks Ltd
SLINFOLD
West Sussex
RH13 7SH

UNITED KINGDOM



Thu, 02 Jul 1998 03:00:00 GMT
 Last Record

says...

Quote:

>Anybody know of any code that will quickly find the last record in a
>field, I have a table with 10,000 records and the first three fields
>are keyed.  I need some code that will locate the first record with
>the required value in the first keyed field and then QUICKLY find the
>last record with the same value in the same keyed field..

>This is for Pdox4.0DOS

>I could use a Locate Next in a While loop until retval is false, but
>thats a bit sluggish..

>Any Ideas ???

Have you tried ?

moveto "table"
moveto [field]
Locate Indexorder ??
If retval then
  Locate Indexorder Last
endif

This Should work...

The Night Diver



Fri, 03 Jul 1998 03:00:00 GMT
 Last Record
Quote:


>says...

>>Anybody know of any code that will quickly find the last record in a
>>field, I have a table with 10,000 records and the first three fields
>>are keyed.  I need some code that will locate the first record with
>>the required value in the first keyed field and then QUICKLY find the
>>last record with the same value in the same keyed field..

>>This is for Pdox4.0DOS

>>I could use a Locate Next in a While loop until retval is false, but
>>thats a bit sluggish..

>>Any Ideas ???

>Have you tried ?

>moveto "table"
>moveto [field]
>Locate Indexorder ??
>If retval then
>  Locate Indexorder Last
>endif

>This Should work...

>The Night Diver

Hmm, If I'd RTFM I'd have picked that up. <blush>
Jim


Fri, 03 Jul 1998 03:00:00 GMT
 Last Record

Quote:

> Anybody know of any code that will quickly find the last record in a
> field, I have a table with 10,000 records and the first three fields
> are keyed.  I need some code that will locate the first record with
> the required value in the first keyed field and then QUICKLY find the
> last record with the same value in the same keyed field..

> This is for Pdox4.0DOS

> I could use a Locate Next in a While loop until retval is false, but
> thats a bit sluggish..

Instead of a locate next, try just checking the values, eg

locate "string"
if not retval then
  ; handle it
  return false
else
  while []="string"
    if atlast() then
      return true
    else
      down
    endif
  endwhile
  up
  return true
endif

--
 W A N T E D   P O S T E R    |\       _,,,---,,_          W A N T E D    

   alias Wayne McDougall     |,4-  ) )-,_..;\ (  `'-'
  D E A D   OR   A L I V E  '---''(_/--'  `-'\_)     D E A D   AND   A L I V E



Sat, 04 Jul 1998 03:00:00 GMT
 Last Record
Wayne: you've got the right idea, but the
true/false logic is off a little.. you are
correct in doing it this way as a concpet,
because compound indexes that include the
first key field don't work correctly, so
you can't count on LOCATE INDEXORDER..\

LOCATE key.field.val
IF NOT retval THEN
   RETURN FALSE
ELSE
   WHILE (TRUE)
       SWITCH
           CASE [other field] = other.val    : RETURN TRUE
           CASE [key field] <> key.field.val : RETURN FALSE
           CASE ATLAST()                     : RETURN FALSE
           OTHERWISE                         : DOWN
       ENDSWITCH
   ENDWHILE
ENDIF

--
Steve Green - Diamond Software Group - Waldorf Maryland USA
CompuServe 71333.2362 - Prodigy TBMG62A -  I am a member of
Borland's TeamB Tech Support staff for PdoxDOS but I do not
represent Borland International in any official capacity.



Sun, 05 Jul 1998 03:00:00 GMT
 Last Record

Quote:
>Have you tried ?
>moveto "table"
>moveto [field]
>Locate Indexorder ??
>If retval then
>  Locate Indexorder Last
>endif
>This Should work...
>The Night Diver

Yes tried that...

 But when you do the Locate Indexorder Last command, it justs drops
you to the end of the table, regardless of the value in the searched
field..  Seems a pointless command, much like issuing END..

Maybe something is not set up correctly in my system that is
preventing that command to work correctly..

Gary S.

**

PC Specialist
BASF Coatings + Inks Ltd
SLINFOLD
West Sussex
RH13 7SH

UNITED KINGDOM



Tue, 07 Jul 1998 03:00:00 GMT
 
 [ 7 post ] 

 Relevant Pages 

1. Help: retrieve LAST record on database of 50.000 record

2. rECORD FOCUS CHANGES TO LAST RECORD AFTER (DATAUNLOCKRECORD) ???

3. Go to First Record and Go to Last Record

4. First/Last Record in a ResultSet

5. can SQL fetch the last record in a table

6. how to select the last record?

7. DTS: Getting the last record for each key in a transformation

8. How to read last record INSERTed

9. Accessing to the last record...

10. Displaying Last Record based on Date

11. How to obtain the last record?

12. Help: getting the last record ID ?!!


 
Powered by phpBB® Forum Software