Cross Database Joins

Posts   
 
    
astrnad
User
Posts: 30
Joined: 23-Jul-2007
# Posted on: 12-Nov-2007 10:02:59   

Hello,

I am using LLBL Gen Pro 2.0, and i have the following situation:

There are 2 seperate Databases and i would like to pull over some data from one database to the other with some manipulation steps included. My first thought was something along the lines:

SELECT db2..table2.ROW_ID AS t2RowId, db1..table1.* FROM db1..table1 LEFT JOIN db2..table2 ON db1..table1.ROW_ID=db2..table2.ROW_ID WHERE t2RowId IS NULL

This should result in giving me datarows from table1 which are not in table2, thus making it possible to work further with the data and synchronize it over. I have generated 2 DALs for the 2 different databases and then thought about a query like

SELECT * FROM db1..table1 WHERE ROW_ID NOT IN (SELECT ROW_ID FROM db2..table2

This makes it possible to split the 2 select statements onto the different data layers, but sadly resulting in a very bad query if one of the 2 tables get really big (which is going to happen). Is there anything else anyone can think about?

Best regards, Alexander Strnad

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 12-Nov-2007 10:33:56   

I have generated 2 DALs for the 2 different databases

You can generate one DAL (one LLBLGen Pro project) which contains entities from the 2 databases.

astrnad
User
Posts: 30
Joined: 23-Jul-2007
# Posted on: 12-Nov-2007 10:49:26   

Walaa wrote:

You can generate one DAL (one LLBLGen Pro project) which contains entities from the 2 databases.

That sounds interesting, does that make it possible to create a corresponding query? I was already thinking about creating a view with this outer join operation.

Best regards, Alexander Strnad

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 13-Nov-2007 12:57:44   

Yes you can make a query across different catalogs.