且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在所有表和所有字段中搜索字符串?

更新时间:2023-11-05 13:31:04

您想研究动态查询".

procedure x:

  define input parameter tbl as character no-undo.
  define input parameter fld as character no-undo.
  define input parameter xyz as character no-undo.

  define variable qh as handle no-undo.
  define variable bh as handle no-undo.
  define variable fh as handle no-undo.

  create buffer bh for table tbl.
  create query qh.
  qh:set-buffers( bh ).
  qh:query-prepare( "for each " + tbl ).
  qh:query-open.

  qh:get-first( no-lock ).
  do while qh:query-off-end = no:
    fh = bh:buffer-field( fld ).
    if fh:buffer-value = xyz then  /* needs special handing if there are array fields in the db ... */
      do:
        display tbl fld bh:recid fh:buffer-value.
        pause.
      end.
    qh:get-next( no-lock ).
  end.

  delete object bh.
  delete object qh.

  return.

end.

for each _file no-lock where not _hidden:

  for each _field no-lock of _file:

    if _data-type <> "character" then next.  /* skip non-char fields */

    run x ( _file-name, _field-name, "urpon frisbee" ).

  end.

end.