table.FETCH_GOTO Function

Syntax

Found_Record_Number as N = Fetch_Goto(N record_number)

Arguments

record_number

The record number to retrieve.

Description

Goto a specific record number in the table, returns positive if record found, else negitive record number.

Discussion

The <TBL>.FETCH_GOTO() method fetches the specified Record_Number from the table or set referenced by <TBL>. If the record number is found in the table, Found_Record_Number equals the Record_Number. If the record number is not found, the method returns an error. The <TBL>.FETCH_GOTO() method can be used regardless of whether an index or query list is active, or record number is the primary index. The <TBL>.FETCH_GOTO() method can be used to point to deleted records (prior to packing the table). Using this technique, you can "undelete" records. (Of course, you could also use the <TBL>.UNDELETE() method.)

Example 

This script sets the primary index to Lastname, then goes to record 5. Since the primary index is Lastname, <TBL>.FETCH_FIND() can only be used to find by Lastname. So to go to record 5, without changing the index to record number order, FETCH_GOTO()is used.

dim tbl as P
tbl = table.open("customer")
indx_lastname = tbl.index_primary_put("Lastname")
tbl.fetch_goto(5)

This script un-deletes record 10.

dim tbl as P
tbl = table.open("customer")
tbl.fetch_goto(10)
tbl.change_begin()
tbl.deleted = ""
tbl.change_end(.T.)

See Also