Board index » delphi » Query across two databases

Query across two databases

I've learned one cannot use a TQuery to perform a query across two
databases (e.g. I cannot write an TQuery.SQL statement that accesses a
table from my application's database and and a table from the master
database, e.g. syslocks).  However, I can perform that same query in
DBExplorer and it works fine, displaying the list of columns I
requested.

Is there an object in Delphi that let's me do this?  a software layer
below TDatasets that I need to dig through in order to perform this
query and get back some results?

I know I can write a  stored procedure, or create two queries to do the
same thing.  But what I really want to do is write one select statement
referring to tables in these two databases, and get back some results I
can work with.

Reply directly to me and I will summarize if there is interest.

Thanks!

mikem

 

Re:Query across two databases


Look up hetrogenous joins in the help file.

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Re:Query across two databases


Two tables in different locations?  You only need one DataSource and
enter the DataSet as your Query component.  
eg DataSource1.DataSet := SQLQuery  
You can do that in the Object Inspector.

Create aliases for each of the directories eg Oracle and LocalDB
Then in your SQL query say something like
SELECT * FROM Oracle.Customers, LocalDB.Employee WHERE........

HTH
rgds, John
In article <365AB70D.6D9DF...@afs.com>, Mike Matlack
<Mike_Matl...@afs.com> writes

Quote

>I've learned one cannot use a TQuery to perform a query across two
>databases (e.g. I cannot write an TQuery.SQL statement that accesses a
>table from my application's database and and a table from the master
>database, e.g. syslocks).  

--
John Matthews

Other Threads