List Database Tables

richhcir2

New Member
Anyone know how to get a list of the tables for a specific database if you've got several connected?

For each _file will give you all tables, how would I narrow this down to a particular db?

Thanks in advance
 
I was hoping to do it on the fly, but I think I'll have to hardcode the database names, repeat the code for each one, and do a for each as you suggest.

Thanks
 
richhcir2 said:
I was hoping to do it on the fly, but I think I'll have to hardcode the database names, repeat the code for each one, and do a for each as you suggest.

Thanks

This will work for you:

Code:
/* main.p */
do x = 1 to num-dbs:
    run main.i string( ldbname(x) + "." ).
end.
 
/* main.i */
for each {1}_file where not(_hidden):
   /* do stuff here */
end.
 
Or you can try using aliases, like so:

DEFINE VARIABLE ix AS INTEGER NO-UNDO.

DO ix = 1 TO NUM-DBS:

CREATE ALIAS 'myalias' FOR DATABASE VALUE(LDBNAME(ix)).

RUN myprog.p.

DELETE ALIAS myalias.

END.

/* myprog.p */
FOR EACH myalias._File
WHERE myalias._File._owner = 'PUB'
AND myalias._File._file-number > 0:

/* do something */

END.
 
Back
Top