- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我注意到我的公司有很多类似这样的存储过程脚本:
alter procedure MyProcedure
@ItemID int
as
BEGIN TRANSACTION
-- Do some stuff, maybe only 1 insert/update statement, maybe many
COMMIT TRANSACTION
重点是,没有 try/catch block ,也没有执行回滚的“if”语句。代码中的任何地方都从未使用过回滚。
那么交易的意义何在?包装在我不知道的交易中还有其他好处吗?我一直认为原因是如果出现问题使用回滚。
在这个程序的范围之外是否有逻辑赋予它意义?
鉴于我有限的知识,这不仅看起来毫无意义,而且看起来很危险,因为如果出现问题,提交将永远不会执行(对吗?),然后您有一个打开的事务并且表被无限期锁定。
最佳答案
如果更新中途失败,它将在 session 关闭时回滚(更具体地说,未能提交,但相当于回滚)。详细讨论了here ,但相关部分是:
Transactions ... Has no persistent effect whatever on the database, through: the action of the ROLLBACK Statement, abnormal termination of the client requesting the transaction, or abnormal termination of the transaction by the DBMS. This may be an action by the system (deadlock resolution) or by an administrative agent, or it may be an abnormal termination of the DBMS itself. In the latter case, the DBMS must roll back any active transactions during recovery.
基本上,他们已将其设置为不会部分执行该过程。尽管如此,由于性能和锁定问题,这可能并不总是理想的方式,但如果没有更多细节,我真的不能说。
关于sql - 如果没有使用 try/catch 或异常逻辑来回滚,那么在事务中包装存储过程是否有意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31120394/
我正在编写两个程序,一个用 C++ 编写,另一个用 Python 编写,以使用 unix 域套接字相互通信。我想做的是让 C++ 代码向 Python 代码发送一个数字,Python 代码又将另一个数
我希望有一个生成器函数,它返回一条线上的点,给定一个最小距离 k。这很简单,可以使用 numpy 完成,如下所示: points = np.linspace(start, end, k) 但是,我想生
根据我的理解,我们一直在用 Git 做一个非常标准的分支模型的项目,描述如下:http://nvie.com/posts/a-successful-git-branching-model/ 我们从“m
我有一张图片,我想单击它以动画形式旋转 90 度,当它再次单击时我希望它以动画形式旋转 -90 度。 对于使用 css3 变换的旋转 im: -moz-transform:rotate(90deg);
我正在尝试将 拖放 Logo 到 2 个 SVG 圆圈 中。在我的代码的帮助下,图像被拖到一个圆圈中,但没有被拖到另一个圆圈中。 如何修改code这样图像可以在两个圆圈之间拖/放? function
我正在使用 python 3.5.2、pandas 0.18.1 和 sqlite3。 在我的数据库中,我有一个列 unix_time 和 INT 自 1970 年以来的秒数。理想情况下我想从 sql
我已经在我的服务器上安装了 SSL。我的问题是如何通过 acegi 插件在选定的 Controller /页面上强制使用 https。 Acegi 插件支持一个属性 forcehttps,当设置为 t
这是我第一次发布查询。我需要帮助。感谢您的帮助。 我同意我已经把我的概率作为一个长篇故事。但很抱歉,我不知道如何缩短它,我的目的是提供有关我的问题的完整信息。 问题:我必须在 Windows 平台上使
我是一名优秀的程序员,十分优秀!