Home Database Mysql Tutorial c语言mysql数据库事务开始、提交、回滚范例_MySQL

c语言mysql数据库事务开始、提交、回滚范例_MySQL

Jun 01, 2016 pm 12:58 PM
affairs language

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;

}

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1246
24
How to Completely Remove Unwanted Display Languages ​​on Windows 11 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 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.

Lock wait timeout exceeded; try restarting transaction - How to solve MySQL error: transaction wait timeout 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

How to set the language of Win10 computer to Chinese? 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.

Fix: Alt + Shift doesn't change language on Windows 11 Fix: Alt + Shift doesn't change language on Windows 11 Oct 11, 2023 pm 02:17 PM

While Alt+Shift doesn't change the language on Windows 11, you can use Win+Spacebar to get the same effect. Also, make sure to use the left Alt+Shift and not the ones on the right side of the keyboard. Why can't Alt+Shift change the language? You have no more languages ​​to choose from. Input language hotkeys have been changed. A bug in the latest Windows update prevents you from changing your keyboard language. Uninstall the latest updates to resolve this issue. You are in the active window of an application that uses the same hotkeys to perform other actions. How do you use AltShift to change the language on Windows 11? 1. Use the correct key sequence First, make sure you are using the correct method of using the + combination.

PHP PDO Tutorial: An Advanced Guide from Basics to Mastery PHP PDO Tutorial: An Advanced Guide from Basics to Mastery Feb 19, 2024 pm 06:30 PM

1. Introduction to PDO PDO is an extension library of PHP, which provides an object-oriented way to operate the database. PDO supports a variety of databases, including Mysql, postgresql, oracle, SQLServer, etc. PDO enables developers to use a unified API to operate different databases, which allows developers to easily switch between different databases. 2. PDO connects to the database. To use PDO to connect to the database, you first need to create a PDO object. The constructor of the PDO object receives three parameters: database type, host name, database username and password. For example, the following code creates an object that connects to a mysql database: $dsn="mysq

MySQL transaction processing: the difference between automatic submission and manual submission 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 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

See all articles