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



Thanks to all who have offered suggestions!

>      c/exec sql
>      c+ select '1'
>      c+   into :success_val
>      c+   from sysibm/sysdummy1
>      c+  where :value like '%&%'
>      c+     or :value like '%+%%'
>      c+     or :value like '%*%'
>      c+     or :value like '%+_%'
>      c+     or :value like '%?%'
>      c/end-exec

Interesting.  I've never seen SQL used like this.  What is the purpose of
sysibm/sysdummy1?  Does SQL require a file to "query" even if it's not
querying it?  Anyway, I can't see where this particular example would offer
a performance benefit over pure RPG, but I could be ignorant on this part.
At the very least, it could be confusing for someone else who has to modify
the application later on.

Maybe I should back up a bit and explain what's behind my original post.

I am allowing the user to search with wildcards.  The data in the search
argument itself may contain any typeable character, including the '%' and
'_'  characters that SQL uses to represent replacement characters.  I am
letting the user use the more familiar '*' and '?' conventions, and
converting them in my program to '%' and '_', respectively.

Because of all this, I need to use the ESCAPE expression as well.

Potential problems that I haven't figured out how to deal with:

Since one of the fields that can be searched is a wide-open text field that
allows any typeable characters, how do I allow the user to scan for the
occurrence of a '?' or '*'?  Maybe I just don't allow it?  Typically, these
wouldn't be searched for anyways, but I'm just trying to allow for maximum
flexibility within the reasonable confines of SQL.  One thing I am doing is
that I give the user the option to modify the SQL statement my program
generates from the prompted information, so if they feel "powerful" enough.
(Just so no one panics, the only users of this application are programmers.)

So, for example, a user may want to search for 'ABC_XYZ*', which is to say
that they are looking for the exact string 'ABC_XYZ' with anything following
it.  Can anyone confirm that the generated SQL should read:
  Where CustName Like 'ABC+_XYZ%' ESCAPE '+'

tia,
db


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.