In .NET, Is it possible to run a nested query from two separate Oracle databases?
E.g.
“SELECT my_value,
FROM table_in_database_1
WHERE my_value IN ( SELECT my_value
FROM table_in_database_2 )”
If so, how would I go about doing this?
Ultimately, this is an effort to overcome an “ORA-01795” error from using an “in” statement with over 1000 items in the conditional list, without having to break the query out into multiple “OR value IN” lists.
You might be able to get away with simply building a database link and joining over that link, but that can have performance issues. Something like this:
Build a link to database 2 on database 1.
Join your table on database 1 to the table on database 2:
Depending on the performance of the link, you may opt to use a hybrid approach for this, involving both a database link and a temporary table.
Build a database link as above. Build a temporary table on database 1 that holds the values to be used in the subquery from database 2.
Copy the values from db2 to db1:
Finally, join your database 1 table to the temporary table.