First, sorry for the delay.
Now, I devised something that should be useful to you:
define temp-table ttTable
field id as integer
field state as character
field city as character
field area as character
index idx is primary unique id.
DEFINE VARIABLE cKeyWords AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE cStateLst AS CHARACTER NO-UNDO.
DEFINE VARIABLE cCityLst AS CHARACTER NO-UNDO.
DEFINE VARIABLE cAreaLst AS CHARACTER NO-UNDO.
/* These variables are just to load the temp-table for the example */
cStateLst = 'Orissa,Orissa,Delhi,Delhi,Goa,Goa,Kerla,Kerla,Andhra,Andhra'.
cCityLst = 'Jaipur,Kuraput,Delhi,New Delhi,South Goa,Panaji,Chochin,Trivandram,Vizag,Hyderabad'.
cAreaLst = 'Town,Village,Town,Village,Village,Town,Town,Village,Town,Village'.
do i = 1 to 10:
create ttTable.
assign ttTable.id = i
ttTable.state = entry(i,cStateLst)
ttTable.city = entry(i,cCityLst)
ttTable.area = entry(i,cAreaLst).
end.
/* For your real code, you don't need this loading part. */
update cKeyWords format "x(20)".
/* now trim the comma separated list to avoid mismatches */
do i = 1 to num-entries(cKeyWords):
assign entry(i,cKeyWords) = trim(entry(i,cKeyWords)).
end.
/* trailing and leading spaces eliminated, let's begin */
assign hBuffer = temp-table ttTable:default-buffer-handle.
for each ttTable:
do i = 1 to hBuffer:num-fields:
if lookup(string(hBuffer:buffer-field(i):buffer-value()), cKeyWords) > 0 then
display ttTable.
end.
end.
Notice it works with a temp-table. The only remarkable change to make it work with a table is this line assign hBuffer = temp-table ttTable:default-buffer-handle.
should be
assign hBuffer = buffer <yourtable>:handle.
Some other notes:
I'm cycling the fields and converting them to string prior to displaying. This is notably slower than building a query dynamically, but since you don't even know which fields they will be querying, I figure it was the best way to do it.
Still, it should be much slower than having proper queries. So maybe thinking of an interface where the user also identifies the field they want to filter would make it possible for you to structure a good dynamic query and get results much more efficiently in case your table is painfully large.
Anyway, let me know if you have any questions, hope this helps.