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



I put the statement into a prepared statement, and no change...

On 5/19/2011 4:25 PM, Alan Campin wrote:
You might turn on SQL monitoring to see the SQL statement being executed but
I think the problem is doing the like with variable. I think you are going
to have to use a prepare statement. I don't think the like will work.

On Thu, May 19, 2011 at 2:57 PM, Gqcy<gmufasa01@xxxxxxxxx> wrote:

I have made one more "tweak" and am getting different results
I have changed the join to a left outer join, so those users that
have NEVER ran the job are listed...

however, in RPGLE, I am getting duplicate data instead of correct data
(If they never have ran the option, the previous records data is being
displayed)
example from STRSQL:

MNUPRF MNUGRP MNUOPT MNUCMD
ANORVELL M 4 CALL ORD500C
ASLOUGH O 6 CALL ORD500C
ASULLENS OE 1 CALL ORD500C
BCHURI ZA 23 CALL ORD500C
BHELMEID AO 1 CALL ORD500C
BPATEL ZA 23 CALL ORD500C
CHANCOCK M 8 CALL ORD500C
CLOOS M 8 CALL ORD500C
CNOBLE ZM 8 CALL ORD500C
CVONHOLT O 6 CALL ORD500C
CWEISS ZA 23 CALL ORD500C
CWIBERG M 4 CALL ORD500C
DACHARYA ZA 23 CALL ORD500C


MENUPF ANORVELL M 4.00 CALL ORD500C
MENUPF ASLOUGH O 6.00 CALL ORD500C
MENUPF ASULLENS OE 1.00 CALL ORD500C
MENUPF ASULLENS OE 1.00 CALL ORD500C -
MENUPF BHELMEID AO 1.00 CALL ORD500C
MENUPF BHELMEID AO 1.00 CALL ORD500C -
MENUPF BHELMEID AO 1.00 CALL ORD500C -
MENUPF CLOOS M 8.00 CALL ORD500C
MENUPF CLOOS M 8.00 CALL ORD500C -
MENUPF CVONHOLT O 6.00 CALL ORD500C
MENUPF CVONHOLT O 6.00 CALL ORD500C -
MENUPF CWIBERG M 4.00 CALL ORD500C
MENUPF DACHARYA ZA 23.00 CALL ORD500C



On 5/19/2011 3:21 PM, Gqcy wrote:
Thanks Michael, reducing to a single select worked.
I didn't show the group by in my code, because I couldn't get SEU to
accept it...


On 5/19/2011 2:48 PM, Schutte, Michael D wrote:
I didn't notice that you were doing a subselect with the strsql query.
Anyway the subquery isn't necessary. Just do this.

select mnuprf, mnugrp, mnuopt, mnucmd, mnuonm, max(mltimstmp) from
pdatalib/menupf
join pdatalib/menulog on mnuprf = mlnuprf and
mnugrp = mlnugrp and
mnuopt = mlnuopt
where mnucmd like (:fmtScanVals)
Group by mnuprf, mnugrp, mnuopt, mnucmd, mnuonm
order by mnuprf, mnugrp, mnuopt
for fetch only;


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gqcy
Sent: Thursday, May 19, 2011 3:27 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: SQL - group by not working for me.

I have a query I can get to work in STRSQL, but not getting it
to compile in SQLRPGLE...

the premise of the query is to return the latest instance of a user
running a menu option. I have a menu file, and a menu log file.
for every menu file record I retrieve, I want to find the "Latest" time
the user ran that option...


I can't get my SQLRPGLE to accept the GROUP BY, or something else is
wrong!!!

here is my SQL that works in STRSQL:
select mnuprf, mnugrp, mnuopt, mnucmd, mnuonm, max(mts) from
(select mnucmd, mnuprf, mnugrp,
mnuopt, mnuonm, mltimstmp as mts
from pdatalib/menupf
join pdatalib/menulog on mnuprf = mlnuprf and
mnugrp = mlnugrp and
mnuopt = mlnuopt
where mnucmd like ('%ORD500%')
order by mnuprf, mnugrp, mnuopt) as list1
group by mnuprf, mnugrp, mnuopt, mnucmd, mnuonm


here is my RPG that won't compile...
each of the fields in my outer select have a "Column XXXXXX or
expression in SELECT list not valid" (SQL0122)

exec sql declare LOAD cursor for
select mnuprf, mnugrp, mnuopt, mnucmd, mnuonm, max(mts) from

(select mnucmd, mnuprf, mnugrp, mnuopt, mnuonm, mltimstmp as mts
from pdatalib/menupf
join pdatalib/menulog on mnuprf = mlnuprf and
mnugrp = mlnugrp and
mnuopt = mlnuopt
where mnucmd like (:fmtScanVals)
order by mnuprf, mnugrp, mnuopt)
ROWS for fetch only;


Thanks...
--
This is the RPG programming on the IBM i / System i (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.

________________________________

Notice from Bob Evans Farms, Inc: This e-mail message, including any
attachments, may contain confidential information that is intended
only for the person or entity to which it is addressed. Any
unauthorized review, use, disclosure or distribution is strictly
prohibited. If you are not the intended recipient, please contact the
sender by reply e-mail and destroy all copies of the original message
and any attachments.


--
This is the RPG programming on the IBM i / System i (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.