FWTemporaryTable
FWTemporaryTable():New([cAlias],[aFields])Creates a temporary table visible only to its owning thread.
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.)
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()
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 NilCreates 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.
- 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.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.