temp-table's life cycle

israelm

New Member
Hi there,

I am having a little troubles with temp tables, basically i don't know their life cycle, i know how to create them, i use the next code:

Code:
DEFINE NEW GLOBAL SHARED TEMP-TABLE tOrder__ NO-UNDO
       FIELD cust_id LIKE customer.cust_id
       FIELD item_id LIKE item.item_id
       FIELD item_desc LIKE item.item_desc
       FIELD item_cost LIKE item.item_cost
       FIELD item_count AS INT    
       FIELD warehouse AS CHAR
    INDEX x cust_id.
I read it this way:

Code:
    DEFINE SHARED TEMP-TABLE tOrder__ NO-UNDO
          FIELD cust_id LIKE customer.cust_id
          FIELD item_id LIKE item.item_id
          FIELD item_desc LIKE item.item_desc
        FIELD item_cost LIKE item.item_cost
        FIELD item_count AS INT
        FIELD warehouse AS CHAR
    INDEX x cust_id.

FOR EACH tOrder__ NO-LOCK:
        {&OUT} tOrder__.cust_id.
    END.
So far everything is ok, but there are some times that i need to read the TT before it has been created, i need to know if it is already created before try to show it otherwise im gonna get an error.

Need to know how to know if it already exist and how to destroy it (once my process has finished need to delete it to continue creating a new one)

If i don't destroy it, how long is gonna be available on the server?

Btw... When i have already created one and i perform some changes on it's fields then get this error message: (I guess it's caused since table already exist and i am trying to modify it)

WebSpeed Error Messages

In procedure progs/norder.html, shared temp-table tOrder__ has a conflict in field, index or undo status. (2075)
Application Error

Unable to run Web object 'progs/norder.html'


Version: 10.2.0.00
OpenEdge Release: 10.2A

Thank's in advance.
Best Regards!
Israel M.
 

RealHeavyDude

Well-Known Member
Using shared defined variables or temp-tables is bad, bad, bad design, bad practice - whatever opinion suits you best ...

The Temp-Table will exist in your session as long as the procedure which defines it as NEW GLOBAL SHARD will persist in the WebSpeed agent's memory. When the procedure goes out of scope the Temp-Table will go out of scope too. Furthermore the definition of the Temp-Table must match exactly in each procedure you reference it. Therefore if you insist on using shared things you should have the definition in an include file which has a parameter for the "NEW". Usually when using NEW GLOBAL SHARED thins they should be defined as NEW GLOBAL in the first procedure in the session.

HTH, RealHeavyDude.
 

israelm

New Member
Hi,

Then what would you suggest to keep temporal information?
Right now im reviewing the file handling to keep the temporal information within a txt file, once i finish using it i can delete it, but i would like to use temp-tables.

If using shared things is not correct how would you perform it? I have not much experience with temp-tables and don't know how the encapsulation works for them. If you have any sample code would be great!

Thanks in advance.
Regards!
 

RealHeavyDude

Well-Known Member
Temp-tables are a perfect vehicle for storing temporary data. You just need to be aware that they are stored in memory until the runtime client runs out of memory and therefore will store them on disk.

Encapsulating the temp-table in a persistent procedure or a class means that the temp-table definition and all methods you need to populate/maintain and retrieve data from it are contained in the persistent procedure or class. That way you are sure that it's available when you need to access it because it's the very same procedure's or class' responsibility.

Unfortunately I don't have an example which I am allowed to share so don't please be mad at me.

Another thing that appears me is that, as you mention in your last post, your 4GL knowledge seams to have potential for development. You should try to get some Progress training to better understand how the 4GL and temp-tables work.

Regards, RealHeavyDude.
 
Top