Define a Temp-Table with a variable containing table name

mikelcid

New Member
Hi everybody!

I want to define a temp-table like another table which name is contained in a character variable. I have to try to do
Code:
 DEFINE PRIVATE VARIABLE tabla AS CHARACTER NO-UNDO INIT "fa_cabfac".
DEFINE PRIVATE VARIABLE tt_tabla LIKE-SEQUENTIAL tabla.
but it does not work.

Anybody can tell me how to do what I want? Thanks!
 
You have to make a dynamic temp-table then.

Code:
define variable cTT as character no-undo.
define variable hTest as handle no-undo.
 
assign cTT = 'temptablename'.
 
run CreateTT (input cTT,output table-handle hTest by-reference).
 
MESSAGE valid-handle(hTest)';' hTest:name
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
 
Procedure CreateTT:
define input parameter cpTTName as character no-undo.
define output parameter table-handle hpTT.
 
create temp-table hpTT.
hpTT:add-new-field('ctTest','CHARACTER').
hpTT:temp-table-prepare(cpTTName).
 
delete object hpTT.
 
end procedure.

HTH,

Casper.
 
You can't work with names stored in variables with static objects. Static objects are all objects that you define with the DEFINE statement. These are resolved at compile time and there is no way to use their names in variables.

You need to use dynamic objects for that. Dynamic objects are all objects created with the CREATE statement at runtime to which you have a handle (variable of type HANDLE). You need to be aware that these dynamic objects were introduced in Progress V9 so they were not available before that. I am just mentioning it because you don't talk about the version of Progress you are talking of ...

Heavy Regards, RealHeavyDude.
 
You need to be aware that these dynamic objects were introduced in Progress V9 so they were not available before that. I am just mentioning it because you don't talk about the version of Progress you are talking of ...

But there is a PRIVATE variable and a LIKE-SEQUENTIAL in his code snippet. So you should easily have been able to guess OE10+ :awink:
 
Back
Top