Home > database > Can a stored procedure in the transaction of execution
Can a stored procedure in the transaction of execution
Time:10-11
I have a stored procedure as shown below, the created
DROP PROCEDURE IF the EXISTS insertIOVandPosData; Delimiter// CREATE procedure insertIOVandPosData ( IN INtest_ID int, IN INvelocity float, IN INposition float) The begin Insert into iovandpos (test_ID, velocity and position) values (INtest_ID INvelocity, INposition); End // Delimiter.
Then call him in MFC and insert a large amount of data, so I just use the transaction processing, the following code
IOVandPos data; Data. Test_ID=1; Data. The position=1; Data. Velocity=1; Char buf [200]. Sprintf_s (buf, "CALL insertIOVandPosData (% d, % f, % f", data. Test_ID, data. The position, data. Velocity); Mysql_query (& amp; Mysql, "START TRANSACTION");//open transaction, if there are no open transactions, so efficiency becomes very low! For (int I=0; i <1000; I++) { If (mysql_query (& amp; Mysql, buf))//executing SQL statements { : : MessageBox (NULL, _T (" fail "), _T (" tip "), NULL);
Such action is not an error, but should not be stored in the database data of article 1000 of the normal, but the result is that there is only one of the database and finally the data (inside a auto-increment primary key can see, only a primary key value of the data of 1000), it is very let a person afflictive,,, have a big answer?
CodePudding user response:
Perform a mysql_query (& amp; Mysql, buf, returns to what, do a return 0