I am trying to write an Oracle procedure to merge data from a remote datalink into a local table. Individually the pieces work quickly, but together they time out. Here is a simplified version of what I am trying.
What works:
Select distinct ProjectID from Project where LastUpdated < (sysdate - 6/24);
--Works in split second.
    Merge into project 
     using (select /*+DRIVING_SITE(remoteCompData)*/ 
            rp.projectID,
            rp.otherdata
            FROM Them.Remote_Data@DBLink rd
            WHERE rd.projectID in (1,2,3)) sourceData -- hardcoded IDs
    On (rd.projectID = project.projectID)
When matched...
-- Merge statement works quickly when the IDs are hard coded
What doesn't work: Combining the two statements above.
    Merge into project 
     using (select /*+DRIVING_SITE(rd)*/ -- driving site helps when this piece is extracted from the larger statement
            rp.projectID,
            rp.otherdata
            FROM Them.Remote_Data@DBLink rd
            WHERE rd.projectID in --in statement that works quickly by itself.
               (Select distinct ProjectID from Project where LastUpdated < (sysdate - 6/24)) 
-- This select in the in clause one returns 10 rows. Its a test database.
    On (rd.projectID = project.projectID)
    )
When matched...
-- When I run this statement in SQL Developer, this is all that I get without the data updating Connecting to the database local. Process exited. Disconnecting from the database local.
I also tried pulling out the in statement into a with statement hoping it would execute differently, but it had no effect.
Any direction for paths to pursue would be appreciated. Thanks.
 
     
     
    