首页 \ 问答 \ Mysql嵌套事务与回滚(Mysql nested transaction with rollback)

Mysql嵌套事务与回滚(Mysql nested transaction with rollback)

有人可以告诉我是否有可能从一个程序中调用另一个程序,如果任何一个程序的任何部分失败,请回滚所有内容?

如果可以,有人可以告诉我一个如何实现这个的小例子吗?

编辑:过程“b”失败,但过程“a”仍然在表“a”中插入一行。 我的理解是,如果插入的任何部分失败,那么所有(两个插入)都会回滚,而这里没有发生。 问题是为什么不呢?

程序“a”

BEGIN
  DECLARE b INT DEFAULT 0;
  DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
  DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;

  START TRANSACTION;
    INSERT INTO a(a)
    VALUES(iA);

     CALL b(iB,LAST_INSERT_ID(),@b);
     SELECT @b INTO b;

     IF b !=1 THEN
        ROLLBACK;
      ELSE
        COMMIT;
  END IF;
END

程序“b”

BEGIN
  DECLARE b INT DEFAULT 0;
  DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
  DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;

  START TRANSACTION;
    INSERT INTO b VALUES(iB,id);
    SET b=1;
  COMMIT;
END;

Can someone tell me if it is possible to call another procedure from within a procedure and if any part of either procedure fails, roll everything back?

If this is possible, can someone please show me a tiny example of how this would be implemented?

EDIT: Procedure "b" fails but procedure "a" still inserts a row into table "a". It's my understanding that if any part of the insert fails that everything (both inserts) is rolled back which is not happening here. The questions is why not?

Procedure "a"

BEGIN
  DECLARE b INT DEFAULT 0;
  DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
  DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;

  START TRANSACTION;
    INSERT INTO a(a)
    VALUES(iA);

     CALL b(iB,LAST_INSERT_ID(),@b);
     SELECT @b INTO b;

     IF b !=1 THEN
        ROLLBACK;
      ELSE
        COMMIT;
  END IF;
END

Procedure "b"

BEGIN
  DECLARE b INT DEFAULT 0;
  DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
  DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;

  START TRANSACTION;
    INSERT INTO b VALUES(iB,id);
    SET b=1;
  COMMIT;
END;

原文:https://stackoverflow.com/questions/12827036
更新时间:2023-07-02 07:07

最满意答案

尝试

$ arm-linux-androideabi-gcc -o conftest -mthumb temp.c /usr/local/lib/libproj.a -lz -lm -ldl

Well, the problem is that android-gcc doesn't understand cygwin path, so we need to use windows path:

$ arm-linux-androideabi-gcc -o conftest -mthumb temp.c -lproj -Lc:/path/to/lib -lproj -lz -lm -ldl

相关问答

更多
  • 配置过程中会要添加NDK目录地址为系统变量,如果是在vi里添加的应该就没有什么问题。如果是手动打开.bash_profile用windows中自带的编辑器添加的话,会出问题,我遇到个这种情况。试了好几遍,才知道。安装一个UltraEdit再打开.bash_profile,不要转换格式,否则也会出问题。
  • Android NDK不再依赖于Cygwin,因此您可以在Windows命令提示符( cmd )内使用NDK构建Boost。 为了使Boost.Build找到NDK,请编辑boost\tools\build\v2\user-config.jam文件并添加以下文本: import os ; androidNDKRoot = C:/android-ndk-r8e ; # put the relevant path using gcc : android : $(androidNDKRoot)/to ...
  • 尝试 $ arm-linux-androideabi-gcc -o conftest -mthumb temp.c /usr/local/lib/libproj.a -lz -lm -ldl Well, the problem is that android-gcc doesn't understand cygwin path, so we need to use windows path: $ arm-linux-androideabi-gcc -o conftest -mthumb temp.c -l ...
  • Cygwin是一种让Windows支持某些Linux功能的方法。 如果你在windows机器上安装cygwin,你就可以在windows上运行一些linux软件(你必须重新编译它,特别是对于cygwin)。 您可以在此处找到它以及有关它的更多信息。 这里的维基页面也有很好的解释。 如果Android NDK需要它,我想Android NDK需要一些Linux功能或工具才能正常工作。 另一种选择可能是在机器上安装Linux并在那里运行Android NDK,因为我认为Linux是Android NDK开发的本 ...
  • 如果您正在使用Windows,则必须使用Windows版本的Android NDK,而不是Linux。 如果您从朋友那里获取了指向Linux可执行文件的配置文件,则需要修复它。 只有这样。 你能发布他给你的配置文件吗? If you're working on Windows, you have to use the Windows version of the Android NDK, not the Linux. If you took a configuration file from your fr ...
  • 你需要: LOCAL_SRC_FILES :=/.cpp /Path/To/Get_Version.cpp You need: LOCAL_SRC_FILES :=/.cpp /Path/To/Get_Version.cpp
  • Cygwin在Windows计算机上模拟GNU / Linux环境。 这意味着你正在使用与Windows命令行不完全相同的“Shell”。 如果您在Windows命令行中键入asdf.exe ,它会尝试在当前目录中查找asdf.exe。 如果它能找到它,则执行该文件。 如果找不到它,它会遍历%PATH%每个目录并再次尝试。 但是,如果在bash中键入asdf (有多种类型的shell,Bourne Again SHell就是其中之一),它不会在当前目录中查找它。 相反,它会尝试在你的一个PATH目录中找到它 ...
  • 在Windows下,以管理员身份运行命令提示符,然后重试: 搜索 - > cmd.exe->右键单击 - >以管理员身份运行 Cygwin是不必要的 - 只需使用Windows本身。 您可以按照Tesseract fork上的README构建说明进行操作。 您所关注的博客使得该过程比必要的更复杂。 Under Windows, run your command prompt as an administrator and try again: Search->cmd.exe->Right-click->Ru ...
  • 谢谢你的回复。 基本上cdt几乎所有的甚至原始参数,如布尔给出错误! 而ndk-build编译没有问题。 现在我将fprintf用于文件,然后检查问题所在并尝试以这种方式进行调试。 这是一种痛苦,但我不必处理cdt / eclipse。 我关上了机票 thank you for all the responses. basically cdt gives error on nearly everything even primitive parameters such as bool!!! while nd ...
  • 对此的链接很好,或者至少是makefile。 问题是LuaJIT库不是为ARM构建的(我使用了objdump -a lualib.a来检查)。 我下载了最新的LuaJIT,在linux下运行脚本并获得了一个ARM库。 现在一切都很好! The linking for this was fine, or at least the makefile was. The problem was the LuaJIT library wasn't built for ARM (I used objdump -a lu ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)