For or Find statement for all tables?

franklin1232

New Member
I was wondering if there is a simple FOR or FIND statement that will search all tables and records in a progress database. I have never seen any function like this with other databases, but my boss swears he changed a bunch of part numbers in symex with only 4 lines of code. He said he didn't have to join any tables. It just found the values in his list and changed them to something else. It would be nice I guess to not have to learn the schema and make sure I have all the tables joined since the partnumber is the key field.
 

MurrayH

Member
Try something like this (this is something I wipped up quite some time ago and I can't remember if it worked):

def var tableName as char no-undo.

def var qh as handle no-undo. /*query handle*/
def var bh as handle no-undo.
def var queryString as char no-undo. /*query string*/
def var queryTest as logical no-undo.

for each _file where _hidden = no no-lock: /*Get all tables*/
tableName = _file._file-name.
/*Create some form of dynamic query*/
queryString = "for each " + tableName + " no-lock".

create query qh. /*Create new query*/
create buffer bh for table tableName. /*Map dynamic buffer to table*/
qh:set-buffers(bh). /*Map table to query though buffer*/
queryTest = qh:query-prepare(queryString) no-error.
if not(queryTest) then
do:
message "Malformed query".
pause.
hide message no-pause.
return.
end. /*if*/

qh:query-open().
qh:get-first().
do while not qh:query-off-end:
/*Do something lick check price field*/
qh:get-next().
end. /*do*/

qh:query-close().
end.
 
Top