Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

DBSetOrder and DBSeek for indexed lookups

Aligns active order and key before seeking.

DBSetOrder and DBSeek for indexed lookupsAdvPL
01 · OVERVIEW

Overview

A DBSeek key must match the selected order expression. DBSetOrder selects a position among open orders, not a universal index number. Zero uses physical order; omitted or negative values leave the order unchanged according to the page. Changing order does not reposition the record. This fragment requires valid nOrder and cKey built for owned EDTRB, including branch when part of the expression. DBSeek with false soft seek distinguishes exact match from absence; do not read fields without checking its return. (TOTVS, n.d., refs. 1–2)

03 · PRACTICAL EXAMPLE

Commented example

// Fragment: nOrder and cKey validated under the caller contract.
If Select("EDTRB") > 0
    EDTRB->(DBSetOrder(nOrder))
    If EDTRB->(DBSeek(cKey, .F.))
        ConOut("Key found")
    Else
        ConOut("Key absent")
    EndIf
EndIf
Expected result

Key presence or absence message; no explicit record update. Alias order and position change. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not confuse logical return with valid position after a failed seek. Preserve caller context; navigation can flush pending changes.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. DBSetOrder. TDN. Accessed on 2026-10-26.
  2. TOTVS. DBSeek. 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