Kbase 16756: How To Implement A Select Distinct In The 4gl
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How To Implement A Select Distinct In The 4gl
How To Implement A Select Distinct In The 4gl
You may write code in the 4gl to implement a select distinct.
Consider the following select statement:
SELECT DISTINCT sales-rep FROM customer
You can write the following 4gl to get the same results:
DEFINE TEMP-TABLE cust-temp
FIELD cust-num LIKE customer.cust-num
FIELD sales-rep LIKE customer.sales-rep
INDEX sales-idx sales-rep DESCENDING.
FOR EACH customer:
FIND cust-temp WHERE
cust-temp.sales-rep = customer.sales-rep NO-ERROR.
IF NOT AVAIL cust-temp THEN DO:
CREATE cust-temp.
ASSIGN
cust-temp.cust-num = customer.cust-num
cust-temp.sales-rep = customer.sales-rep.
DISPLAY cust-temp.sales-rep.
END. /* end if not avail */
END. /* end for each customer */
This method is much slower than the select distinct since it
is reading the entire customer table. You should probably just
use the select distinct in your 4gl code because of its
performance benefits.
Progress Software Technical Support Note # 16756