Hello
Database link is a good technique for running a query against multiple database, but you will need to statically define the DB you want to access.
Best regards
CREATEDATABASELINKdev_linkCONNECTTOsystemIDENTIFIEDBY password
USING'(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =sapdev)(PORT = 1527)) ) (CONNECT_DATA = (SID = DEV) ) )';
select * from sapsr3.REORGJOBS@dev_link;
drop database link dev_link;
25383 - Database links, synonyms, remote DB