c语言mysql数据库事务开始、提交、回滚范例_MySQL
1、 事务提交模式修改:修改数据库提交模式为0[手动提交]
memset ( sql, 0x00, sizeof( sql ) );
memcpy ( sql, "set autocommit=0;", 17 );
if( mysql_query( sock, sql ) ){
sprintf( g_acTrcMsg, "关闭自动提交模式失败[%d][%s]", mysql_errno( sock ), mysql_error( sock ) );TRCLOG1
return -1;
}
2、 事务开始
memset ( sql, 0x00, sizeof( sql ) );
memcpy ( sql, "start transaction;", 18 );
if( mysql_query( sock, sql ) ){
sprintf( g_acTrcMsg, "建立事务失败[%d][%s]", mysql_errno( sock ), mysql_error( sock ) );TRCLOG1
return -1;
}
3、 事务回滚
memset ( sql, 0x00, sizeof( sql ) );
memcpy ( sql, "rollback;", 9 );
if( mysql_query( sock, sql ) ){
sprintf( g_acTrcMsg, "事务回滚失败[%d][%s]", mysql_errno( sock ), mysql_error( sock ) );TRCLOG1
return -1;
}
4、 事务提交
memset ( sql, 0x00, sizeof( sql ) );
memcpy ( sql, "commit;", 7 );
if( mysql_query( sock, sql ) ){
sprintf( g_acTrcMsg, "提交事务失败[%d][%s]\n", mysql_errno( sock ), mysql_error( sock ) );TRCLOG1
return -1;
}
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
1378
52
How to Completely Remove Unwanted Display Languages on Windows 11
Sep 24, 2023 pm 04:25 PM
Work on the same setup for too long or share your PC with others. You may have some language packs installed, which often create conflicts. So, it’s time to remove unwanted display languages in Windows 11. Speaking of conflicts, when there are multiple language packs, inadvertently pressing Ctrl+Shift changes the keyboard layout. If not taken care of, this can be a hindrance to the task at hand. So, let’s jump right into the method! How to remove display language from Windows 11? 1. From Settings press + to open the Settings app, go to Time & Language from the navigation pane and click on Language & Region. WindowsI click the ellipsis next to the display language you want to remove and select Remove from the pop-up menu. Click "
3 Ways to Change Language on iPhone
Feb 02, 2024 pm 04:12 PM
It's no secret that the iPhone is one of the most user-friendly electronic gadgets, and one of the reasons why is that it can be easily personalized to your liking. In Personalization, you can change the language to a different language than the one you selected when setting up your iPhone. If you're familiar with multiple languages, or your iPhone's language setting is wrong, you can change it as we explain below. How to Change the Language of iPhone [3 Methods] iOS allows users to freely switch the preferred language on iPhone to adapt to different needs. You can change the language of interaction with Siri to facilitate communication with the voice assistant. At the same time, when using the local keyboard, you can easily switch between multiple languages to improve input efficiency.
How to set the language of Win10 computer to Chinese?
Jan 05, 2024 pm 06:51 PM
Sometimes we just install the computer system and find that the system is in English. In this case, we need to change the computer language to Chinese. So how to change the computer language to Chinese in the win10 system? Now Give you specific operation methods. How to change the computer language in win10 to Chinese 1. Turn on the computer and click the start button in the lower left corner. 2. Click the settings option on the left. 3. Select "Time and Language" on the page that opens. 4. After opening, click "Language" on the left. 5. Here you can set the computer language you want.
Lock wait timeout exceeded; try restarting transaction - How to solve MySQL error: transaction wait timeout
Oct 05, 2023 am 08:46 AM
Lockwaittimeoutexceeded;tryrestartingtransaction - How to solve the MySQL error: transaction wait timeout. When using the MySQL database, you may sometimes encounter a common error: Lockwaittimeoutexceeded;tryrestartingtransaction. This error indicates that the transaction wait timeout. This error usually occurs when
MySQL transaction processing: the difference between automatic submission and manual submission
Mar 16, 2024 am 11:33 AM
MySQL transaction processing: the difference between automatic submission and manual submission. In the MySQL database, a transaction is a set of SQL statements. Either all executions are successful or all executions fail, ensuring the consistency and integrity of the data. In MySQL, transactions can be divided into automatic submission and manual submission. The difference lies in the timing of transaction submission and the scope of control over the transaction. The following will introduce the difference between automatic submission and manual submission in detail, and give specific code examples to illustrate. 1. Automatically submit in MySQL, if it is not displayed
Exploring the boundaries of agents: AgentQuest, a modular benchmark framework for comprehensively measuring and improving the performance of large language model agents
Apr 11, 2024 pm 08:52 PM
Based on the continuous optimization of large models, LLM agents - these powerful algorithmic entities have shown the potential to solve complex multi-step reasoning tasks. From natural language processing to deep learning, LLM agents are gradually becoming the focus of research and industry. They can not only understand and generate human language, but also formulate strategies, perform tasks in diverse environments, and even use API calls and coding to Build solutions. In this context, the introduction of the AgentQuest framework is a milestone. It not only provides a modular benchmarking platform for the evaluation and advancement of LLM agents, but also provides researchers with a Powerful tools to track and improve the performance of these agents at a more granular level
How to change the language display of vivox60pro vivox60pro system language setting method
Mar 23, 2024 am 09:06 AM
1. Click [System Management] in the phone settings menu. 2. Click the [Language] option. 3. Select the system language you want to use.
The principles and application scenarios of MySQL transactions
Mar 02, 2024 am 09:51 AM
The principle and application scenarios of MySQL transactions In the database system, a transaction is a set of SQL operations. These operations are either all executed successfully or all fail and are rolled back. As a commonly used relational database management system, MySQL supports transaction characteristics and can ensure that the data in the database is consistent, isolated, durable and atomic. This article will start with the basic principles of MySQL transactions, introduce its application scenarios, and provide specific code examples for readers' reference. The principle of MySQL transactions: My


