× 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.



"GROUPING" goes with grouping sets. It gives you a way to tell when a
value is null because a subtotal is being reported, as opposed to the value
being null because of other reasons.





From: Alan Campin <alan0307d@xxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)"
<rpg400-l@xxxxxxxxxxxx>
Date: 10/28/2014 03:58 PM
Subject: Re: SQL5011 with multi row fetch and integer type in Data
structure
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>



Never saw the grouping function before. Interesting.

On Tue, Oct 28, 2014 at 1:39 PM, <darren@xxxxxxxxx> wrote:

Here is my statement:

select IPROD,
ifnull((select IDESC from IIML01
where IPROD=T2.IPROD
fetch first row only),'') as IDESC,
ifnull((select IITYP from IIML01
where IPROD=T2.IPROD
fetch first row only),'') as IITYP,
grouping(Market), // 1 means null because of totalling
ifnull(Market,''),
sum(ILNET) as Sales
from T2
group by grouping sets(
(IPROD),
(IPROD, Market))
order by IPROD, grouping(Market) desc, Sales desc




From: Alan Campin <alan0307d@xxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)"
<rpg400-l@xxxxxxxxxxxx>
Date: 10/28/2014 03:36 PM
Subject: Re: SQL5011 with multi row fetch and integer type in Data
structure
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>



Could you send your SQL statement. I don't see what GROUP BY would return
a
0 or 1.

On Tue, Oct 28, 2014 at 1:27 PM, <darren@xxxxxxxxx> wrote:

As far as I can tell, its not validating on the actual value being
returned
at this stage, however, in this case, I'm using the GROUPING aggregate
function, which, according to the SQL manual, returns a small integer
with
a value of 0 or 1.





From: Alan Campin <alan0307d@xxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)"
<rpg400-l@xxxxxxxxxxxx>
Date: 10/28/2014 03:21 PM
Subject: Re: SQL5011 with multi row fetch and integer type in
Data
structure
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>



What does the data base table look like? Is this field a small integer?
Could you send the field from DSPFFD so we can see what type it is?

DB2 does not support a unsigned integer that I can see.

The reason that it is probably working on a single fetch is that SQL
precompiler issues individual move instructions to fields in the
program
so
RPG would convert from signed to unsigned integer.

When you do multiple row fetch, the SQL precompiler just passes a
pointer
to the data structure and the data just get moved in so it would not
get
converted to unsigned integer.

Anyway, that is my best guess.

On Tue, Oct 28, 2014 at 12:26 PM, <darren@xxxxxxxxx> wrote:

That was a little off. The final "Good" was a typo on the
declaration.
It
should show that I can use integer when fetching one row at a time:
Good:
D C1arr DS qualified INZ
D PROD 35
D DESC 50
D ITYP 2
D TotInd 3u 0
D Market 5
D Sales 19 7
exec sql fetch C1 into :C1arr;




From: darren@xxxxxxxxx
To: "midrange-RPG RPG message board" <rpg400-l@xxxxxxxxxxxx>
Date: 10/28/2014 02:23 PM
Subject: SQL5011 with multi row fetch and integer type in Data
structure
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>




I have the following declaration and then fetch statement. When I
define
TOTIND as a 3u 0 (meaning unsigned integer) or a 3i0 (signed
integer),
the
compiler gives me SQL5011. But, if I define TOTIND as 3p 0 (packed
3,0)
it
compiles fine. Does anyone know what rule I'm breaking by using an
integer
here? The declare statement is going to be feeding a GROUPING(FIELD)
function into this variable. Also, if I don't use multi fetch,
instead
just fetching 1 row at a time, its fine.

Fails:
D C1arr DS qualified dim(100) INZ
D PROD 35
D DESC 50
D ITYP 2
D TotInd 3u 0
D Market 5
D Sales 19 7
D
exec sql fetch C1 for 100 rows into :C1arr;

Good:
D C1arr DS qualified dim(100) INZ
D PROD 35
D DESC 50
D ITYP 2
D TotInd 3p 0
D Market 5
D Sales 19 7
D
exec sql fetch C1 for 100 rows into :C1arr;


Good:
D C1arr DS qualified dim(100) INZ
D PROD 35
D DESC 50
D ITYP 2
D TotInd 3p 0
D Market 5
D Sales 19 7
D

exec sql fetch C1 into :C1arr;

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



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


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



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


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



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


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




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.