<<

I’d like some input on how others handle doing text string
searches for words with apostrophes (i.e. Johnson’s).  I’m
working on a search form and my default quote setting is a single apostrophe (‘)
and therefore they can’t search for words containing a single apostrophe. 
I’m thinking of temporarily setting quotes to (“), doing the search
and then setting it back.  
>>

No, don't do that, you're only asking for trouble.

You need to escape any string the user enters for search purposes by doubling 
up the quotes:

SET VAR vString = (SRPL(.vString, '''', '''''', 0))

In other languages the first thing I do is write a function QSTR() which does 
exactly this.  In R:Base, since we have a simple SRPL function, it's much 
lighter weight (although less readable) to use SRPL directly in the code.

In the past, I've requested having a QSTR function added directly to the R:Base 
language to do this.  I think it would be clearer when reading the code and, 
more importantly, it would be aware of the current database QUOTE setting so 
the programmer wouldn't have to worry about it.
--
Larry

Reply via email to