Chuck,
I used your example, simplified.
select * from qgpl/QASYJSJ5 where locate ('ARPINS2',JSLIBL ) <> 0
ARPINS2 is a library to be deleted.
SQL returns nothing found.
Based on this, library ARPINS2 has not been used in any job since March 20, 2014.
Is my logic and findings conclusive?
Paul
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Tuesday, July 15, 2014 5:26 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: Scaning field JSLIBL from QAUDJRN outfile QASYJSJ5
On 15-Jul-2014 15:41 -0500, Steinmetz, Paul wrote:
I have an outfile QASYJSJ5 from QAUDJRN.
What would be the easiest way to scan field JSLIBL (Library list),
searching for a specific library?
Example, searching for DBU10 from below.
Library list: SYSCHG SYS QSYS QSYS2 QHLPSYS QUSRSYS QIDU DBU10 TAATOOL RXS TCPIP502
One way, but not necessarily the easiest; the LOCATE is used in first equivalence [not equal] predicate instead of LIKE predicate, under the assumption the query may optimize by performing the LOCATE just once instead of the LIKE processing being performed and then the LOCATE doing effectively the same thing a second time:
WHERE LOCATE('DBU10 ', JSLIBL)<>0
AND MOD(LOCATE('DBU10 ', JSLIBL)-1, 10)=0
Test Case:
create table QTEMP/QASYJSJ5
( SHOULD_BE_FOUND for FOUND CHAR
, JSLIBL CHAR(430)
)
;
insert into QTEMP/QASYJSJ5 values
('N', 'DBU10NOT QSYS QSYS2 QUSRSYS ZZDBU10')
,('Y', 'QSYS QSYS2 QUSRSYS DBU10 OTHER ')
,('N', 'QSYS QSYS2 QUSRSYS ZZDBU10 OTHER ')
,('Y', 'SYSCHG QSYS QSYS2 QUSRSYS DBU10 ')
,('N', 'QSYS QSYS2 QUSRSYS DBU10NOT OTHER ')
,('Y', 'DBU10 QSYS QSYS2 QUSRSYS OTHER ')
;
select * from QTEMP/QASYJSJ5
WHERE JSLIBL LOCATE('DBU10 ')<>0
AND MOD( LOCATE('DBU10 '), 10)=0
; -- to see why 2nd predicate is required, drop it and retest:
select rrn(a),a.* from QTEMP/QASYJSJ5 as a
WHERE JSLIBL LOCATE('DBU10 ')<>0
; -- w/out 2nd predicate, the _last_ lib may be selected in error
--
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.