Question on FETCHING exact DATA

skunal

Member
Hi,
I have one question. I have one Town table which contains the data as "YORK", "YORKSHIRE" etc.
And there is one program which passes an input string as "YORKSHIREABC" .
And i have to write the program to find the exact value of town and pass it back. I cant us "=" symbol as i may get the Towns with some EMBEDDED characters like in example above "ABC" is embedded with "YORKSHIRE" so i am using INDEX.
But if i use INDEX then the condition would satisfy for the "YORK" also as its present in DB.

I wrote the code:
for each towns where INDEX(ip-string,towns.town) > 0:
disp towns.town.
end.
but here i find i get both York and Yorkshire as output .SO how can i now just make such an arrangement so that only exact match should be displayed (like YORKSHIRE)
Can anyone please help me to find some solution on this. I guess we can use LENGTH function .Please if u can find some solution on this.
 
actually YORKSHIRE is not exact match. Both records are good to be answer. So you can return temp-table which contains both records or put another condition.

define temp-table ttowns no-undo
field name as character
field l as integer
index i0 l desc.

for each towns where INDEX(ip-string,towns.town) > 0:
create ttowns.
ttowns.name = towns.town.
ttowns.l = lenght (towns.town).
end.
for each ttowns use-index i0:
return ttowns.name.
end.
 
Top