BUFFER handle VS TEMP-TABLE handle

gummbeey

New Member
Whats the difference between the two statements below

DEF TEMP-TABLE ttCust...
bhttCust1 = TEMP-TABLE ttCust:HANDLE.
bhttCust2 = BUFFER ttCust:HANDLE.

I know they have different properties/methods because it lists them on the Help file under "Temp-table Object Handle" and "Buffer Object Handle".

But I wanna know why you can do it in two ways? It looks like the bhttCust2 is more useful.


 

jongpau

Member
The temp-table handle is the handle to the table itself. You can use this one to "send" whole (dynamic) temp-tables, including structure and data, to and from AppServer and non AppServer procedures. However, in order to access the data in the temp-table, you will need the table's buffer-handle.

The buffer handle is the handle to the buffer of the table. You can use this one to actually access the data in the temp-table. You cannot send buffer handles to and from AppServer procedures (but you can send it as a parameter between procedures on the client). The buffer handle does not actually contain the temp-table, it is just a handle to access the data.

Did that make sense??

So to access a temp table that was created in procedure 1 to procedure 2 on the client you can do:
Code:
RUN procedure.p (input buffer-handle).

And to, for instance receive a temp-table from an AppServer procedure you would do something like this:
Code:
RUN procedure.p ON appserver-handle (OUTPUT temp-table-handle).  
buffer-handle = temp-table-handle:DEFAULT-BUFFER-HANDLE.

The really fun thing is that, in combination with dynamic queries, you can use these 2 handles to work with temp-tables without actually knowing what these look like and they are portable with the same handles of dynamically created temp-tables (see CREATE TEMP-TABLE in the help)
 

gummbeey

New Member
Thanks for the replies. I did some quick programs and this is what I got.

The TEMP-TABLE ttCust:HANDLE is a pointer to the actual temp-table, which allows me to dynamically create/modify a temp-table.

Whereas the BUFFER ttCust:HANDLE is pointer to a what I call a "record holder" which allows to dynamically create/delete/update records.
 

jongpau

Member
Basically you are right; but...

- I don't think you can modify a static temp table through its handle. A dynamic temp-table you can modify until you have called "temp-table-prepare". After that the thing should be set in stone and if you do need to change its structure you will have to create a new one and destroy the old (by the way: never forget to destroy dynamic temp tables or you get yourself some nice memory leaks)

- You forgot that you can also read records through the buffer's handle, but that is "nit picking" really :awink:

By the way, you can also use dynamic buffers (so buffer handles) on database tables. This just in case you did not know that you can do so.


Now some advice you really haven't asked for and if you know this already, just forget I ever wrote this:

If the terminology used within Progress is a little new to you maybe you should have a look at the Progress documentation that *should* have come with your licenses. Your should have either or both of these:
- A stack of books (yes, real paper ones the lot of them weighing a ton)
- A CD called the "Electronic Documentation"

I personally like the edocs because they do not collect dust on my shelves and are easy to use, search and navigate and contain the same information as the paper ones. You can install the edocs on your computer and then search and read the complete collection of Progress documentation (and that is quite a bit). There are several voumes ranging from "the basics" of Progress and how to get started etc to complete reference guides.

HTH
 
Top