Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Copy new records from Oracle table to SQL Server table then update Oracle table.

$
0
0

I am copying records from an Oracle table that are flagged Incomplete(2) to a SQL Server table that are new to the SQL Server.  Then I want to update the Oracle table's flag for those records to Complete(1) before any other program writes to it. I am using SQL Server 2008r2 and Oracle 11.2.  I was thinking of putting this in a Stored Procedure and running it as a Job on SQL Server.

I tried putting the INSERT and UPDATE in BEGIN TRANSACTION COMMIT TRANSACTION clause but I get an error on the UPDATE statement something about can't start a new transaction.

Then I tried:

BEGIN TRY

INSERT statement

END TRY

BEGIN CATCH

SELECT "errors"

RETURN

END CATCH

BEGIN TRY

UPDATE statement

END TRY

BEGIN CATCH

SELECT "errors"

RETURN

END CATCH

This works but I am concerned that another program might write to the Oracle table before the UPDATE statement can run.  Any help with this would be greatly appreciated.

Fred


Fred Schmid


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>