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



Creating the file (or maybe it's a field option, I don't recall) with sort sequence *LANGIDSHR and compiling the program(s) with the same option will allow the system to do case insensitive searches which will allow you to get rid of the UPPER() functional. If you sort the results, it will also order them in a more natural way (boo and Baa will show as Baa, boo instead of boo, Baa).

Also, make sure you have an index over your file over any fields that you are doing an equals comparison with and any fields in your order by clause. Order of the fields in the index makes a difference. You want the fields in your where clause first and then the fields in your order by clause. Also, make sure that any existing logical files you think it should use do not have select/omit criteria in them. The query optimizer will not consider those. Finally, if you have an index you think it should be using and it doesn't, try ordering the results by the first field in the index.

Matt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Wilt, Charles
Sent: Friday, January 18, 2008 9:54 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Interupting an rpg sql search

So the problem isn't that you can't interrupt it, the problem is that it is taking too long.

I see two problems with your SQL.

Using the UPPER() function on a column.
Using '%ZONE%'

-- both of which force a full table scan.

I don't know off the top of my head if it will help, but first try reordering the where clause like
so:

Dynstm = select * from clientfile where city = 'NY'
And upper(name) like '%ZONE%'
fetch first 25 rows only

Otherwise try:

With table as ( select * from clientfile
Where city = 'NY'
)
Select * from tbl
Where upper(name) like '%ZONE%'


Might be helpful depending on how many of the 1/2 million records have city = 'NY'.

If none of the above helps (enough), then the only option is to build a separate dictionary file.
Still, depending on the results you're looking for with the LIKE, things could get tricky.

For instance, '%ZONE%' would find:
'AUTOZONE'
'END ZONE TAVERN'

The first one is the problem, the second can be found by having a dictionary file built like so
Key token
1234 END
1234 ZONE
1234 TAVERN

Then having an index over the dictionary that can be used by using: 'ZONE%'
Additionally, consider the SOUNDEX function:
http://www.systeminetwork.com/artarchive/index.cfm?fuseaction=viewNewsletterArticle&articleID=54444&we
bID=1001

or http://tinyurl.com/29rsqn

HTH,

Charles Wilt
Software Engineer
CINTAS Corporation - IT 92B
513.701.1307
wiltc@xxxxxxxxxx


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of tim
Sent: Friday, January 18, 2008 9:27 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Interupting an rpg sql search

Here is the code I am refering to. The user may want to search for
%beauty%
in the name field of the client file. The client file has about 1/2
million
records. So this may take a while. This also needs to be done interactive
since they want what they want when they want it :)

Dynstm is built by user requirements. So it can be more complicated.

Dynstm = select * from clientfile where upper(name) like '%ZONE%'
and city = 'NY' fetch first 25 rows only

exec sql set option datfmt=*usa;
exec sql prepare s2 from :dynstm;
exec sql declare c2 cursor for s2;
exec sql open c2;
exec sql fetch c2 into :thefileds;
dow sqlcod = 0;
blah blah blah
enddo

The user will hit enter and can wait as long as a minute. So, in turn,
they
close out the client access window which really makes a mess.




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of rob@xxxxxxxxx
Sent: Friday, January 18, 2008 8:57 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Interupting an rpg sql search

I take it you're talking about the RPG we all know and love and not some
client/server version like VARPG?
I don't think you'll find a whole lot on "event programming" with RPG or
RPGLE. That's what might interrupt a long running process.
You're pretty much restricted to ENDJOB or SysReq. (Typically mapped to
Shift-Esc on a PC keyboard). Normally you'd use option 2. However, on
some long runners like that, I've had to use option 90 to force a sign off
because option 2 would tell me something like it couldn't be halted during
the middle of some critical operation or some such thing.

I'd really evaluate that SQL statement. Traditional wisdom is to do a
STRDBG UPDPROD(*YES) and do not specify a program name. After the program
is done you can do a DSPJOBLOG and you'll see tons of SQL stuff in there
to look at.

Another consideration is CHGQRYA QRYTIMLMT(15)

After doing a little poking around, you might post the SQL statement and
we can see if you really flubbed it up. Hey, even I've made mistakes. :-)

I don't suppose there's some way to throw a halt indicator? (Ducking and
running.)

Rob Berendt
--
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





"tim" <tim2006@xxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
01/18/2008 08:43 AM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
"'RPG programming on the AS400 / iSeries'" <rpg400-l@xxxxxxxxxxxx>
cc

Subject
Interupting an rpg sql search






I have a SQLRPGLE program that does a search using "like" over a large
file.
The search can take a bit a time in some cases. I would like to be able to
stop the search by hitting a key (say esc key tied to an attention
program).



Can this be done? Or are there other techniques I can use. I've tried the
"fetch first 25 rows only" clause, but the search still can take a long
time.





--
This is the RPG programming on the AS400 / 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 AS400 / 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 AS400 / 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 e-mail transmission contains information that is intended to be confidential and privileged. If you receive this e-mail and you are not a named addressee you are hereby notified that you are not authorized to read, print, retain, copy or disseminate this communication without the consent of the sender and that doing so is prohibited and may be unlawful. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please delete and otherwise erase it and any attachments from your computer system. Your assistance in correcting this error is appreciated.
--
This is the RPG programming on the AS400 / 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 ...

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.