如何获取 DB2 上的当前隔离级别? [英] How to obtain current isolation level on DB2?

查看:104
本文介绍了如何获取 DB2 上的当前隔离级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解事务在 DB 中的工作方式,为此我编写了以下测试 SQL:

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;

所有工作都如我所料,即事务正确回滚并且数据库中没有新条目,但如果我再次运行此代码,Data Studio 会在第一行显示错误:

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.

所以我的问题是:有没有办法获得当前的隔离级别,为什么我不能设置隔离级别超过 1 次?

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.我正在使用 DB2/iSeries V5R4.

PS. I am using DB2/iSeries V5R4.

PPS.对不起我的英语不好

PPS. Sorry for my bad English

推荐答案

你大概可以从特殊寄存器当前隔离.你得到 SQL0428 因为您在设置隔离级别之前没有 COMMIT 或 ROLLBACK,并且该会话中有事务仍在处理中.

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.

这篇关于如何获取 DB2 上的当前隔离级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆