How to create a transaction with isolation level in SQL.
I'v tried something like this, but obviously it does not work:
INSERT INTO test(col1) VALUES ('test')
SET TRANSACTION ISOLATION LEVEL read stability;
COMMIT WORK;
I'm using SQL DB2 LUW
CodePudding user response:
https://www.ibm.com/docs/en/db2/11.5?topic=information-sqlj-set-transaction-clause says:
You can execute SET TRANSACTION only at the beginning of a transaction.
https://www.ibm.com/docs/en/i/7.5?topic=statements-set-transaction says:
The SET TRANSACTION statement can only be executed when it is the first SQL statement in a unit of work, unless:
all previous statements executed in the unit of work are SET TRANSACTION statements or statements that are executed under isolation level NC, or
it is executed in a trigger.
I'm not a user of DB2, but this seems to say that you must SET TRANSACTION before your INSERT. This matches my experience in other RDBMS products.
CodePudding user response:
Look at the SET CURRENT ISOLATION statement.