There are two different isolation levels you can use within a session that will insure that the data read at the beginning of the transaction doesn't change until the transaction with one of the isolation levels mentionned below is committed
BOL article on Isolation Levels
Serializable
Statements cannot read data that has been modified but not yet committed by other transactions
No other transactions can modify data that has been read by the current transaction until the current transaction completes.
Other transactions cannot insert new rows with key values that would fall in the range of keys read by any statements in the current transaction until the current transaction completes.
REPEATABLE READ
Specifies that statements cannot read data that has been modified but not yet committed by other transactions and that no other transactions can modify data that has been read by the current transaction until the current transaction completes.
The main difference between the two, is that the serializable isolation level prevents inserting new data anywhere within the range of rows.
USE MYDATABASE
GO
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
GO
BEGIN TRANSACTION;
sp_insert_operation
COMMIT TRANSACTION
There is also the option of setting snapshot isolation at the database level, but I don't believe that would give you the level of isolation you are looking for.
Here is the relevant documentation ALTER DATABASE look under snapshot isolation
Update on Serializable
http://blogs.msdn.com/
Serializable isolation level relies on pessimistic concurrency control. It guarantees consistency by assuming that two transactions might try to update the same data and uses locks to ensure that they do not but at a cost of reduced concurrency - one transaction must wait for the other to complete
Copying Joao's answer (from question comments) so this Q can have an A.
No, there is no problem with that. Single inserts/updates are atomic and reads are always consistent. However, you don't have transaction blocks in MongoDB (executing multiple inserts/updates atomically). – joao Feb 24 '14 at 13:26
Best Answer
A transaction is started for each statement that occurs outside of an explicit transaction block. Whether a commit is automatically issued following the statement is dependent on the RDBMS configuration. MySQL has the autocommit option, SQL Server has IMPLICIT_TRANSACTIONS, PostgreSQL is always auto commit.
PostgreSQL:
InnoDB:
SQL Server: