Continuing from my previous question about accessing tables given a char variable of the table name... (which has now enabled me to create the best lookup program in the universe! )
Now that I have a handle to my table e.g. htable.
Is it possible to define a temp-table like the table the handle refers to?
i.e. if htable is a handle to the customer table.
can I do something like...
define temp-table tt-mytable like htable.
...?
That particular code tells me that htable is an ambiguous or unknown table.
Any help is appreciated!
Thanks
Oliver
No, you can't do it like that, the reason being is that the hTable handle is unknown at COMPILE time, which is when DEFINE requires it. But, you can use the CREATE TEMP-TABLE statement and point it to the handle of your table (look at the CREATE-LIKE method).
Brilliant!
Thanks!
Another quick question.
I have managed to create the temp-table this way inside a procedure (thank you).
Is there any way of passing a handle to the table as an output param so that the calling procedure can access the temp-table?
Thanks very much!
Oliver
Yeah, that's not an issue. If both procedures are in the same session, then just pass the handle. Instead of defining the variable to store the handle of the created TT, define it as an output parameter instead.
If there is an AppServer involved then you need a TABLE-HANDLE parameter instead of a HANDLE.
For portability between local and appserver sessions, have a look at BY-REFERENCE