Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Safe lookups with DbSeek, Found and SoftSeek

Distinguishes a found record from approximate positioning.

Safe lookups with DbSeek, Found and SoftSeekAdvPL
01 · OVERVIEW

Overview

DbSeek requires an active index compatible with the key. A single numeric-field index uses a numeric key; other cases must follow the index expression and field lengths. True SoftSeek can position at a greater key without finding the requested value: false does not authorize treating that record as a match. Found retrieves the search result; inspect it immediately in the same context. The DBSeek page gives conflicting lLast guidance; the example omits it and disables SoftSeek. The fragment selects neither index nor key format: both are explicit caller preconditions. (TOTVS, n.d., refs. 1–2)

Return value

No single return value: this is a composite workflow.

03 · PRACTICAL EXAMPLE

Commented example

// Fragment: current alias open, active index and compatible cKey.
lFound := DbSeek(cKey, .F.)
If lFound .And. Found()
    // Read matched record fields only here.
    ConOut("Key found")
Else
    ConOut("Key not found")
EndIf
Expected result

Outcome depends on key and data. The example repositions the alias without writing or restoring its prior position. Declare key and logical variable in the caller. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate alias, index, filter and branch before lookup. Save/restore context when required and do not interleave another search before Found.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

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