Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Orders, indexes and key expressions

IndexKey([nOrdem]) -> cKey

Checks the index expression before building a search key.

Orders, indexes and key expressionsAdvPL
01 · OVERVIEW

Overview

The active order determines logical sequence and the expression used by DbSeek/MsSeek; its number is not universal across environments. IndexKey() returns the current expression as text; a missing order returns empty text, while a closed area can also raise an error. Search keys must follow component order, types and widths. DBMS physical indexes, RDD orders and business keys are related but not interchangeable. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

IndexKey([nOrdem]) -> cKey
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed563()
    // Requires an open area with indexes; block not invoked.
    Local bInspect := {|| IndexKey()}
    ConOut(ValType(bInspect))
Return Nil
Expected result

Prints B. Evaluation in the actual context yields the current order expression. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Inspect SIX/actual expression, restore the caller’s order and verify fields after searches. Changing order neither sorts an array nor automatically creates a new physical index.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. IndexKey. TDN. Accessed on 2026-10-27.
  2. TOTVS. MsSeek. TDN. Accessed on 2026-10-27.
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