|
Hi all,
Hope you are well.
A REST API I am working on returns data split into pages: many calls are
necessary to get the complete set of data, but in this way, the user
doesn't wait too much for the first page. Data are retrieved within an RPG
ILE service program by a static SQL statement which applies some dynamic
filters that come within the request.
Everything works fine, except the same static SQL statement is run at least
twice to know the total number of rows (a simple count(*)) and the rows
themselves page by page.
Now, on the same data retrieved by this SQL statement, others select
statements must be run to get some totals according to different group by
clauses in order to present the data set distribution to the final user.
I hardly accepted the idea of running the same SQL statement (which, by
the way, is pretty complex) at least twice to get both the total and the
row, but I can't stand the idea of even more runs to get data distribution.
There might be errors in my design of how the procedure should work,
nonetheless, I wonder if a single common table expression might be used
many times to serve many different select statements, as I would avoid the
use of other solutions like global temporary tables.
Any suggestion is really appreciated.
Many thanks
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.