× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



s/b are NOT transferred by the list (Server), no attachments are actually.

Charles

On Tue, Jul 28, 2020 at 10:37 AM Charles Wilt <charles.wilt@xxxxxxxxx>
wrote:

Pictures are transferred by the list.

Best choice, include the SQL statement, otherwise if you must send a pic,
you'll have to upload it to an image service (imgur.com) and post a link.


Charles

On Tue, Jul 28, 2020 at 10:32 AM Maria Lucia Stoppa <mlstoppa@xxxxxxxxx>
wrote:

@Charles
Yes, I am using offset and fetch first, as you can see in the picture of
my
last answer to you.

Il giorno mar 28 lug 2020 alle ore 18:16 Charles Wilt <
charles.wilt@xxxxxxxxx> ha scritto:

Are you LIMITing the cursor to 50 rows?

If you're using LIMIT/OFFEST or FETCH FIRST in the cursor, that would
make
sense.

Charles

On Tue, Jul 28, 2020 at 9:40 AM Maria Lucia Stoppa <mlstoppa@xxxxxxxxx>
wrote:

@Charles
I did it, but it doesn't work.
[image: image.png]
wTotalRows equals to 50 which is wRowsToRead instead of 994, as it
should
be.

Il giorno mar 28 lug 2020 alle ore 16:21 Charles Wilt <
charles.wilt@xxxxxxxxx> ha scritto:

Again, use the GET DIAGNOSTICS after the OPEN, not the FETCH.

The grouping stuff is in 7.2, some of the OLAP functions are, but
there's
been a bunch added.

Charles

On Tue, Jul 28, 2020 at 8:11 AM Maria Lucia Stoppa <
mlstoppa@xxxxxxxxx

wrote:

@Charles
I've just tried and it returns the number of fetched rows only,
not
the
total result set length.

I'll take a look at those new features you suggested, hoping they
exist
at
V7R2 also.


Il giorno mar 28 lug 2020 alle ore 15:58 Charles Wilt <
charles.wilt@xxxxxxxxx> ha scritto:

On Tue, Jul 28, 2020 at 3:17 AM Maria Lucia Stoppa <
mlstoppa@xxxxxxxxx

wrote:

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.


GET DIAGNOSTIC DB2_NUMBER_ROWS is what you want to look at here.

If the previous SQL statement was an OPEN or a FETCH which
caused
the
size of the result table to be known, returns the number of
rows in
the
result
table. For SENSITIVE cursors, this value can be thought of as an
approximation since rows inserted and deleted will affect the
next
retrieval of
this value. Otherwise, the value zero is returned.


Run it after you OPEN your cursor, before you FETCH.


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.


Have you looked at the OLAP functions in addition to ROLLUP,
CUBE
and
grouping sets?






https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/db2/rbafzolapexp.htm







https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/db2/rbafzgroupbyclause.htm


When I started writing SQL on the AS/400, (sub)totaling
required an
extra
statement.
That is no longer the case.

Charles
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any
subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com



--

Maria Lucia Stoppa
mlstoppa@xxxxxxxxx
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com



--

Maria Lucia Stoppa
mlstoppa@xxxxxxxxx
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



--

Maria Lucia Stoppa
mlstoppa@xxxxxxxxx
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.