I am using the Teradat 14 .NET provider. I want to execute the following SQL in a single transaction:
delete mydb.mytable;
insert into mydb.mytable select * from mydb.myothertable;
This issue I have encountered is that, while the delete is instant, the insert takes a few seconds. If a select occurs after the delete, but before the insert has committed (as opposed to before the insert has been executed), no rows return. Therefore, I don't want the results of both statements to be visible by any other SELECT
statement until the transaction is committed. IsolationLevel.Snapshot
has a description that best matches what I want:
Reduces blocking by storing a version of data that one application can read while another is modifying the same data. Indicates that from one transaction you cannot see changes made in other transactions, even if you requery.
The problem is that Teradata 14 appears to not support this type of transaction:
The isolation level is not supported by this version of Teradata Database.
What do I have to do to keep the results of the delete
and insert
from being visible to other select
statements until the transaction has been committed?
Edit
Here is the code I am using after dnoeth's answer. I am using a Teradata session and am putting all SQL into a single string which is still returning no results if a select is done after the delete, but before the insert as completed. dnoeth, am I doing it as you suggested? Notice that there is no TdTransaction
object since I am doing bt;et;
in the SQL.
Using con As TdConnection = GetNewConnection()
Using cmd As TdCommand = con.CreateCommand
cmd.CommandText = "bt;delete mydb.mytable;insert into mydb.mytable select * from mydb.myview;et;"
cmd.ExecuteNonQuery()
End Using
End Using