Usina BRAdvPL Guide
Sign in
← All topics
CLASSUnder review

FWTemporaryTable

FWTemporaryTable():New([cAlias],[aFields])

Creates a temporary table visible only to its owning thread.

FWTemporaryTableAdvPL
01 · OVERVIEW

Overview

Requires DBAccess 4.2 build 20141119 or newer. New accepts alias and {name,type,length,decimals} structure; SetFields defines fields and Create creates the table. Delete removes it and closes its alias. This example uses GetNextAlias and does not share tables across processes. The community reference illustrates SetFields/Create/Delete; its RetSqlName line is not reproduced because the class provides specific names for queries and TC functions. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

FWTemporaryTable():New([cAlias],[aFields])

Methods

SetFieldsDefines field structure.o:SetFields(aFields)
AddIndexAdds an index to the definition.o:AddIndex(cIndexName,aFields)
CreateCreates temporary table.o:Create()
GetAliasReturns open alias.o:GetAlias() -> cAlias
DeleteRemoves table and closes alias.o:Delete()
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed451()
    Local oTmp := FWTemporaryTable():New(GetNextAlias())
    Local cAlias
    // Test temporary table only.
    oTmp:SetFields({{"ED_COD","C",6,0},{"ED_QTD","N",10,2}})
    oTmp:AddIndex("01",{"ED_COD"})
    oTmp:Create()
    cAlias := oTmp:GetAlias()
    ConOut(cAlias)
    oTmp:Delete()
    FreeObj(oTmp)
Return Nil
Expected result

Creates an empty structure, prints its alias and deletes the temporary table. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Ensure Delete also runs in error handling. AddIndex names have at most two characters. Do not close another routine’s areas.
  • 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.
  2. thalysjuvenal/advpl-specialist. Cross-database examples; commit d80599b. 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