Search by an string (use matches)

Hello!

See, i have to perform a search in a table using matches operator. But, here, we use special caracters "é, ê, ã, í, ü", etc, etc.... and "matches" undestand that "a" and "á", for example, are different. If I do

display "a" = "á".

it returns "yes", but if i do

display "a" matches "á".

it return "no", and i NEED a "yes" from this comparation......

Someone know how to do that????

Thanks a lot. that´s URGENT!!!!
 

cmorgan

New Member
I know it isn't an ideal solution, but you could try something like

<PRE><BIG>
display "a" matches replace( YourString, "á", "a" ).

</BIG></PRE>

You could even write a function to handle all of the relevant replacements, so you could write

<PRE><BIG>
FUNCTION ReplFunction returns character
( input StartString as character ):

Define variable ReplFunction as character no-undo.

assign ReplFunction = replace( StartString, "á", "a" )
ReplFunction = replace( ReplFunction, "é", "e" )
etc.......

return ReplFunction.

END.

display "a" matches ReplFunction( YourString ).

</BIG></PRE>

HTH
 
Reply

Ya. That´s a good idea. But it doesn´t work, in my case. I teel you why.

I used a function to substitute the "wrong" caracters "á, é" etc. by "good" caracters "a, e" etc. But when i used that in a "for each table", where "table" has about 50000 records, i have a slow search. When I use "matches", it´s work better.

For example:

def var x as char.
def var y as char.

assign x = "andré".

/* i have 50000 records in table */

/* this is fast, but i have a record with table.name = "andre",
that doesn´t find it */

for each table where
table.name matches ("*andré*") no-lock:
create table2.....etc etc....
end.


/* this work correctly, but is VERY, VERY slow */

for each table no-lock:
if freply(table.name) <> freply(x) then next.
create table2.....etc etc....
end.

/* freply() is a function that substitute wrong caracters by good caracters */

It´s me wrong????

See ya
 

cmorgan

New Member
How about this:

Def var x as char no-undo.

assign x = freply("andré")

for each table where
table.name matches ( "*" + x + "*" ) no-lock:
create table2.....etc etc....
end.
 

M-HT

Member
No that wouldn't work, because if table.name = "andré" it doesn't match freply("andré").
How about this combined solution:

def var x as char no-undo.
def var y as char no-undo.

x = freply("andré").
y = freply1(x).

for each table where table.name matches y no-lock:
if freply(table.name) <> x then next.
create table2.....etc etc....
end.

The function freply1 replaces all "good" characters (a, e, ...) with a ".".
The matches operator would filter all words but ".ndr." where . can be any character and the if command would allow only "andre", "ándre", "andré" and "ándré".
I think it's correct and faster than the solution without the matches part.
 

Ofi

New Member
Collation table problem

display "a" = "á".
returns "yes",
=>
Your collation table (in convmap.cp or/and in startup parameter or/and in DB ) is not correct for these characters!
Correct return is "no"
See Progress Internationalization Guide
 
Top