Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread best way to find if one character exists in a stringfield value
Tue, Feb 28 2006 1:03 PMPermanent Link

"Monte Etherton"
Hi Tim (and fellow elevate fans Smiley,

I need to search for a single character value's existence in a string field
called 'CharCodes'.

For example, I need to know if 'K' exists in CharCodes.AsString 'GADKE'.

I scan all records using:
  if pos('K', dm.TableName_CharCodes.AsString) > 0 then...

I have an index on the CharCodes field, but don't think it's being used in
this case due to the field value itself not being in any order, and the fact
I am using the "pos" function.

Would having the field value in order (ie 'ADEGK') help any?

Is there a more efficient way to do this?

Thanks for any advice,

Monte

Tue, Feb 28 2006 1:09 PMPermanent Link

Chris Erdal
> For example, I need to know if 'K' exists in CharCodes.AsString
> 'GADKE'.

If you want to limit the number of rows returned by a Query to optimise
this, you could do a

SELECT ...
FROM ...
WHERE CharCodes LIKE '%K%'

and then every row has one!

--
Chris
Tue, Feb 28 2006 2:12 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Monte


It sounds like you're using the OnFilter event, if so I suggest you switch to using a filter. DBISAM is brilliant in that the filters are almost identical to sql. So you could set a filter along the lines of CharCodes LIKE '%K%' (nicked from Chris's post).

Roy Lambert
Image