How to obtain current isolation level on DB2?

ⅰ亾dé卋堺 提交于 2019-12-10 22:22:26

问题


I am trying to learn how transactions work in DB and to do this I wrote the following test SQL:

SAVEPOINT STOP_HERE ON ROLLBACK RETAIN CURSORS;

INSERT INTO TESTSCHEMA."test" (ID, NAME) VALUES (89898, 'SDFASDFASD');

ROLLBACK TO SAVEPOINT STOP_HERE;

SELECT * FROM TESTSCHEMA."test";

After execution of this code the one row is added into the table. But if I add the following line at the beginning:

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;

all work as I expected, i.e. transaction correctly rolled back and no new entries in DB, but if I run this code again the Data Studio shows me error in the first line:

[SQL0428] SQL statement can not be launched.

So my questions are: Is there a way to obtain current isolation level and why I can't set isolation level more than 1 time?

I would be very thankful for all answers and links.

PS. I am using DB2/iSeries V5R4.

PPS. Sorry for my bad English


回答1:


You can probably get the current isolation level from special register current isolation. You get the SQL0428 because you didn't COMMIT or ROLLBACK before setting the isolation level, and there were transactions still in process in that session.



来源:https://stackoverflow.com/questions/4946986/how-to-obtain-current-isolation-level-on-db2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!