Progress
Programming
Handbook


Dynamic Buffers for Dynamic Temp–tables

All dynamic buffer attributes and methods are available to dynamic temp–tables. For more information on dynamic buffers, see "Database Triggers" and the Progress Language Reference manual sections on Buffer Object Handle and Buffer–field Object Handle.

Every dynamic temp–table is created with at least one buffer, just like a static temp–table. This default buffer’s object handle is returned by the DEFAULT–BUFFER–HANDLE( ) method. It is through this buffer handle that you have access to the records and fields in the temp–table object as follows:

dyn-buff-hdl = dyn-tt-hdl:DEFAULT-BUFFER-HANDLE.
dyn-buff-hdl:BUFFER-CREATE.
buff-fld = dyn-buff-hdl:BUFFER-FIELD(3). 

The DEFAULT–BUFFER–HANDLE( ) method may not be called until the TEMP–TABLE–PREPARE( ) method has been called, since the default buffer is not created until then.

In addition, several new methods have been created to enhance the use of dynamic buffers for dynamic temp–tables:

The CREATE BUFFER statement will now support both temp–tables and buffer handles, as follows:

CREATE BUFFER dyn-buff-hdl FOR TABLE dyn-tt-hdl. 

The following program illustrates the use of buffers and buffer–fields in dynamic temp–tables. It uses a dynamic query which is described in "Using Dynamic Widgets":

p-ttdyn2.p
/* p-ttdyn2.p - a join of 2 tables  */
DEFINE VARIABLE tth4 AS HANDLE.
DEFINE VARIABLE btth4 AS HANDLE.
DEFINE VARIABLE qh4 AS HANDLE.
DEFINE VARIABLE bCust AS HANDLE.
DEFINE VARIABLE bOrder AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE fldh AS HANDLE EXTENT 15.

bCust = BUFFER customer:HANDLE.
bOrder = BUFFER order:HANDLE.

CREATE TEMP-TABLE tth4.
tth4:ADD-FIELDS-FROM(bCust,"address,address2,phone,city,comments").
tth4:ADD-FIELDS-FROM(bOrder,"cust-num,carrier,instructions,PO,terms").
tth4:TEMP-TABLE-PREPARE("CustOrdJoinTT").
btth4 = tth4:DEFAULT-BUFFER-HANDLE.

FOR EACH customer WHERE cust.cust-num < 6, EACH order OF customer:
    btth4:BUFFER-CREATE.
    btth4:BUFFER-COPY(bCust).
    btth4:BUFFER-COPY(bOrder).
END.

/* Create Query  */
CREATE QUERY qh4.
qh4:SET-BUFFERS(btth4).
qh4:QUERY-PREPARE("for each CustOrdJoinTT").
qh4:QUERY-OPEN.

REPEAT WITH FRAME zz DOWN:
    qh4:GET-NEXT.
    IF qh4:QUERY-OFF-END THEN LEAVE.
    REPEAT i = 1 TO 15:
        fldh[i] = btth4:BUFFER-FIELD(i).
        DISPLAY fldh[i]:NAME FORMAT "x(15)"
        fldh[i]:BUFFER-VALUE FORMAT "x(20)".
    END.
END.

btth4:BUFFER-RELEASE. 
DELETE OBJECT tth4. 
DELETE OBJECT qh4. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095