Working with temp tables

Zadock

New Member
I am pretty new in the concept of separating business logic from user logic. We migrated from Progress V9.1D to Openedge V11.1. We are in the process of overhauling our existing application so that it can run on the web. I have read the documentations that came with Openedge but still, it is not clear to me what happens in the following statement:

define temp-table temptable1 like customer.

These are my questions:
1) Do I need to be physically connected to the sports2000 database to be able to define temptable1?
2) In a situation where Appserver is present, how does it handle the above statement?
3) When loading our application, we were using the -db parameter. How does this change/work where an Appserver is involved since I understand it is the work of the Appserver to handle requests between client and server?

Thanks in advance.
 

Stefan

Well-Known Member
  1. since customer is a database table, you need to be connected to the database. Try that statement from a procedure editor that is not connected to the database and see what happens.
  2. the AppServer /can/ define the temp-table like a database table (since the AppServer /is/ connected to the database) - the client can be passed the temp-table. If the client does not know the schema - it can be part of an output table-handle, prodataset-handle, serialized xml or json. It is also possible to define the temp-table and all its fields explicitly (without any database references), put that in an include and use that definition on both client and server. The server can then buffer-copy database contents to the temp-table, pass the temp-table to the client, the client can then do whatever it wants with the temp-table, pass this back etc.
  3. the client does not connect the database anymore, but connects to an AppServer. The AppServer connects to the database.
 

jongpau

Member
You can use "define like" on the client side as well as long as you compile your code before you run it - the compiler sticks the temp-table definition in the r-code (all fields, formats, help, labels, indices etc). It is a great "quick and easy" way to ensure you have the fields you need available to you. There is however always a negative to the positive in that it may not be very efficient to define a temp-table like a database table, especially if you only need to use a few fields out a table that has a lot of fields. The size of your r-code will be larger than it should because of all the space needed for your temp-table. If you start using before-tables on your temp-table this effect is doubled. Finally, depending on how you fill the temp-table you may be sending a copying a unnecessary data to the client.
 

Zadock

New Member
Hi Paul,

Does this mean that after compliling, my r-code can run without connecting to the sports2000 database since all the field have been mapped to the r-code?
 

jongpau

Member
Hi Paul,

Does this mean that after compliling, my r-code can run without connecting to the sports2000 database since all the field have been mapped to the r-code?


Yes, you can run your compiled code and use the temp-tables to transport data to and from the appserver(s). You do (of course) have to make sure that you do not try to access any databases from your client code or you will get a database <dbname> is not connected error.
 
Top