Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

DBSetIndex

DBSetIndex( cIndex ) --> Nil

Opens an existing index without creating keys.

DBSetIndexAdvPL
01 · OVERVIEW

Overview

DBSetIndex adds the specified index orders to those already open. Existing orders mean the new order is not automatically assumed active; without orders, the first new order takes control. It does not create the file and is not DBCreateIndex. ED_NEWIDX is only a pre-existing owned index compatible with example EDTRB, not a standard product index. EDTRB identifies only an owned test table already open with the required schema and permissions; examples are not intended for standard tables. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

DBSetIndex( cIndex ) --> Nil

Parameters

cIndex
CharacterRequired

Existing index name compatible with table/RDD.

Return value

Nil; not a logical success indicator.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed338()
    // Requires existing ED_NEWIDX; neither creates nor replaces it.
    If Select("EDTRB") > 0
        EDTRB->(DBSetIndex("ED_NEWIDX"))
    EndIf
Return Nil
Expected result

Requests index opening; does not claim it became active when other orders existed. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check RDD, alias and pending operations. Navigation can flush updates; preserve context under the caller contract and handle errors in the complete routine.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. DBSetIndex. 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