Consultor Eletrônico



Kbase 16532: Example: How to make OPEN QUERY interruptible
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Example: How to make OPEN QUERY interruptible


This Knowledgebase Entry shows a work-around to make
a potentially slow OPEN QUERY statement seem
interruptible to the end user.

The OPEN QUERY statement is not interruptible. This
can be frustrating if an end-user inadvertently starts
a query that turns out to be very slow, possibly because
the table is not indexed to support the query. The following
code sample shows how to make a query interruptible by
using a temp-table to store intermediate results.


/***** Sample code to run against the sports database *****/

DEFINE TEMP-TABLE T-customer LIKE customer.
DEFINE QUERY rrr FOR T-customer.
DEFINE BROWSE Brrr QUERY rrr DISPLAY name cust-num WITH 5 DOWN.
DEFINE FRAME f1 Brrr AT ROW 2 COLUMN 2.

DO ON STOP UNDO, LEAVE:
RUN pop-t-table.
END.

OPEN QUERY rrr FOR EACH T-customer.
ENABLE Brrr WITH FRAME f1.

WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.


/****** Internal Procedure ********************/


PROCEDURE pop-t-table.

REPEAT ON ENDKEY UNDO, LEAVE
ON STOP UNDO, LEAVE:
FIND NEXT customer.
CREATE T-customer.

/* In version 8.1A and later, the following
line may be used instead of the field-by-field
copy */
/* BUFFER-COPY customer TO T-customer. */

T-customer.name = customer.name.
T-customer.cust-num = customer.cust-num.
PAUSE 1. /* to artificially slow it down */
END.

END. /* procedure */


Progress Software Technical Support Note # 16532