Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Temporary table operations

FWTemporaryTable():New(cAlias,aFields); Create(); Delete()

Defines the lifecycle of a thread-local temporary table.

Temporary table operationsAdvPL
01 · OVERVIEW

Overview

FWTemporaryTable takes an alias and field structure; Create materializes the table, GetAlias returns the work area and Delete removes the table and closes its alias. Visibility is limited to the creating thread, not other jobs. Documentation requires DBAccess 4.2 Server build 20141119 or later. AddIndex defines indexes with names up to two characters. This fragment prepares structure without calling Create; materialization needs a test connection and cleanup on errors too. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

FWTemporaryTable():New(cAlias,aFields); Create(); Delete()
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed519()
    Local aFields := {{"ED_CODE","C",10,0}}
    // Prepared constructor; create/delete only in a test context.
    Local bBuild := {|| FWTemporaryTable():New(GetNextAlias(),aFields)}
    ConOut(ValType(bBuild))
Return Nil
Expected result

Prints B; the uninvoked block creates no table. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Use a unique alias, define fields/indexes before Create and ensure Delete on normal/error exits. Do not share temporary aliases across threads.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

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