How to search all character columns of all tables in a database for a keyword ?.

willy

New Member
hi i would like to search all character columns of all tables in a database for a keyword ?.
 

rusguy

Member
Don’t you think it will take forever to execute?

In the case you still want to do it, then something like this would work

Code:
for each _field no-lock where _data-type = "character",
  each _file of _field no-lock:
  disp _field._field-name _file._file-name.
  run checkField(_file._file-name, _field._field-name, "yourKeyWordGoesHere").
end.
procedure checkField:
  define input parameter cTable as character no-undo.
  define input parameter cField as character no-undo.
  define input parameter cKeyWord as character no-undo.
  define variable hQuery as handle no-undo.
  define variable hBuffer as handle no-undo.
  create buffer hBuffer for table cTable.
  create query hQuery.
  hQuery:set-buffers(hBuffer).
  hQuery:query-prepare("for each " + cTable + " no-lock where " + 
                       cTable + "." + cField + " matches ""*" + cKeyword + "*""").
  hQuery:query-open().
  hQuery:get-first().
  do while not hQuery:query-off-end:
    disp hBuffer:buffer-field(cField):buffer-value.
    hQuery:get-next().
  end.
  hQuery:query-close().
  delete object hBuffer.
  delete object hQuery.
end procedure.
 

tamhas

ProgressTalk.com Sponsor
If this is an on-going rather than one time occurrence, read up about word indexes.
 
Top