Dynamic Query for Multiple DBs with same tables

diebelch

New Member
Hello All,

I am trying to write a program to scan through database tables and compare the values in the selected tables.

2 DBs are connected with the same table names and schema but different data.

I am trying to open a dynamic query for table XXX in database AAA and database BBB.

How do I qualify the database names in the below code ?

create buffer bh for table b_file._file-name.
create buffer bh2 for table b_file._file-name.
qh:set-buffers(bh).
qh2:set-buffers(bh2).
qh:query-prepare("for each AAA." + b_file._file-name +
" no-lock use-index " + DICTDB._index._index-name +
" :").
qh2:query-prepare("for each BBB." + TRIM(b_file._file-name) +
" no-lock use-index " + DICTDB._index._index-name + " :").

I tried putting the DB qualifier in the QUERY-PREPARED statement and in-front of the CREATE BUFFER statement but nothing seems to work.

Any advise would be appreciated !!
 
Hi,

I'm not certain anymore as it's been years since catering for multiple DBs in this fashion...

However, I think you need to define ALIAS for the two DBs before utilising them in this fashion.

Look for ALIAS or ALIAS_DB command or similar? You may run into issues if both DBs aren't available during compile time. Not sure if that was a bug or not.

Happy coding

Breck
 
Back
Top