提交 a77d5d5b authored 作者: Thomas Mueller's avatar Thomas Mueller

New function SCOPE_IDENTITY().

上级 23c0fae8
...@@ -105,12 +105,14 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -105,12 +105,14 @@ public class TriggerObject extends SchemaObjectBase {
load(session); load(session);
Connection c2 = session.createConnection(false); Connection c2 = session.createConnection(false);
boolean old = session.setCommitOrRollbackDisabled(true); boolean old = session.setCommitOrRollbackDisabled(true);
Value identity = session.getScopeIdentity();
try { try {
triggerCallback.fire(c2, null, null); triggerCallback.fire(c2, null, null);
} catch (Throwable e) { } catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_EXECUTING_TRIGGER_3, e, getName(), throw Message.getSQLException(ErrorCode.ERROR_EXECUTING_TRIGGER_3, e, getName(),
triggerClassName, e.toString()); triggerClassName, e.toString());
} finally { } finally {
session.setScopeIdentity(identity);
session.setCommitOrRollbackDisabled(old); session.setCommitOrRollbackDisabled(old);
} }
} }
...@@ -179,6 +181,7 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -179,6 +181,7 @@ public class TriggerObject extends SchemaObjectBase {
Connection c2 = session.createConnection(false); Connection c2 = session.createConnection(false);
boolean old = session.getAutoCommit(); boolean old = session.getAutoCommit();
boolean oldDisabled = session.setCommitOrRollbackDisabled(true); boolean oldDisabled = session.setCommitOrRollbackDisabled(true);
Value identity = session.getScopeIdentity();
try { try {
session.setAutoCommit(false); session.setAutoCommit(false);
triggerCallback.fire(c2, oldList, newList); triggerCallback.fire(c2, oldList, newList);
...@@ -192,6 +195,7 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -192,6 +195,7 @@ public class TriggerObject extends SchemaObjectBase {
} }
} }
} finally { } finally {
session.setScopeIdentity(identity);
session.setCommitOrRollbackDisabled(oldDisabled); session.setCommitOrRollbackDisabled(oldDisabled);
session.setAutoCommit(old); session.setAutoCommit(old);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论