Kbase P75229: How to limit the number of records returned by a dynamic query?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/06/2005 |
|
Status: Verified
GOAL:
How to limit the number of records returned by a dynamic query?
GOAL:
Is it possible to limit the number of records returned by a dynamic query?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
FIX:
This can be done with MAX-ROWS. This specifies the maximum number of records to be returned by the query. Any other records satisfying the query are ignored and no error is raised. The limit is imposed before any sorting occurs; Progress retrieves records up to the number specified and then sorts those.
Sample code:
DEFINE VARIABLE qh AS HANDLE NO-UNDO.
DEFINE VARIABLE qString AS CHARACTER NO-UNDO.
qString = "for each customer max-rows 15".
CREATE QUERY qh.
qh:SET-BUFFERS(BUFFER customer:HANDLE).
qh:QUERY-PREPARE(qString).
qh:QUERY-OPEN.
REPEAT :
qh:GET-NEXT().
IF qh:QUERY-OFF-END THEN LEAVE.
DISPLAY custnum.
END.
qh:QUERY-CLOSE().
DELETE OBJECT qh.