Recno queries and DbGoTo positioning
Separates the SQL cursor from the positioned real table.
Overview
A recno query selects the real table R_E_C_N_O_ under an alias, converts the numeric field when needed, and scans a read cursor. Each recno can position the real table with DbGoTo. The query neither locks nor validates a later update: recheck existence, branch, deletion and business rules before writing. This example uses an already-open caller-owned cursor with numeric A1RECNO and an open SA1, without writes. Preserve SA1 position separately when repositioning it. (Sources: refs. 1–2.)
Commented example
#Include "Protheus.ch"
User Function Ed609()
// Uninvoked block; cQuery must contain numeric A1RECNO.
Local bPosition := {|cQuery| SA1->(DbGoTo((cQuery)->A1RECNO))}
ConOut(ValType(bPosition))
Return NilBuilds the positioning step without opening a query or changing a table. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- During scanning, Eof and DbSkip belong to the cursor, not the positioned table; use a dynamic alias and close only your cursor.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.