Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

DBSkip and record navigation

Traverses a bounded sequence with movement and end checks.

DBSkip and record navigationAdvPL
01 · OVERVIEW

Overview

A loop needs a start, end condition and movement. DBGoTop starts at the first logical position; DBSkip follows order and filter, and EOF must be checked before field access. The example visits at most three visible records on owned EDTRB and only counts without exposing data. Filters and deleted-record settings affect the count; it is not the table total. The alias stays at the reached position, possibly EOF. (TOTVS, n.d., refs. 1–2)

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"
User Function Ed341()
    Local nCount := 0
    If Select("EDTRB") > 0
        EDTRB->(DBGoTop())
        While !EDTRB->(Eof()) .And. nCount < 3
            nCount++
            EDTRB->(DBSkip(1))
        EndDo
        ConOut(cValToChar(nCount))
    EndIf
Return Nil
Expected result

Count from zero to three, depending on visible records. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Keep movement inside the loop. Ensure a reading context without pending changes; restore area and position when the caller requires it.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. DBSkip. TDN. Accessed on 2026-10-26.
  2. TOTVS. DBGoTop. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha