Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

DBUseArea

DBUseArea( [lNewArea], [cDriver], cFile, cAlias, [lShared], [lReadOnly] ) --> Nil

Opens a table in a new work area with an owned alias.

DBUseAreaAdvPL
01 · OVERVIEW

Overview

DBUseArea returns Nil and requires an available driver, connection and file/table. Default false lNewArea can close the current area: this demonstration chooses true. File paths belong to the server rather than the SmartClient. The fragment only prepares a callback for an owned ED_TEST table already existing in the TOPCONN connection. GetNextAlias supplies the name, opening is shared and read-only, and closing would target the created alias. It creates neither connection nor table. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

DBUseArea( [lNewArea], [cDriver], cFile, cAlias, [lShared], [lReadOnly] ) --> Nil

Parameters

lNewArea
LogicalOptional

True opens a new area; false defaults to the current area.

cDriver
CharacterOptional

Compatible RDD; omission uses the configured default.

cFile
CharacterRequired

Existing file/table in driver context.

cAlias
CharacterRequired

Available alias owned by the routine.

lShared
LogicalOptional

Shared mode subject to driver and other access.

lReadOnly
LogicalOptional

Read-only mode.

Return value

Nil; the routine must handle failures.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed343()
    Local cAlias := GetNextAlias()
    Local bOpen
    // ED_TEST must exist. Callback is not invoked.
    bOpen := {|| DBUseArea(.T., "TOPCONN", "ED_TEST", cAlias, .T., .T.)}
Return Nil
Expected result

Alias name obtained and callback prepared; no table opened. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • The invoking routine must check failures and close its owned alias on normal and error paths; preserve the caller area.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. DBUseArea. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR

Was this content helpful?

👍 Like 0👎 Dislike 0

Sign in to rate this article.

0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha