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



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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.