2017-08-29 14 views
-1

私はFedora 25のMariaDB 10.1.25とSQLエディタとしてDBeaverでこのトランザクションを実行しようとしています。MariaDBトランザクションの試行でエラーが発生しました

各クエリだけで正常に動作しますが、トランザクションブロックでラップすると常に失敗します。

BEGIN; 
INSERT INTO quality.tb_account (email, password, registration_date, active, screen_name) 
     VALUES ('[email protected]', 'password', CURRENT_DATE(), TRUE, 'user11'); 
INSERT INTO quality.tb_account_roles (account_id, role_id) 
     VALUES (LAST_INSERT_ID(), 1); 
COMMIT; 

エラーは次のいずれかです。

SQL Error [1064] [42000]: (conn:2) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO quality.tb_account (email, password, registration_date, active, scre' at line 2 
Query is : BEGIN; 
INSERT INTO quality.tb_account (email, password, registration_date, active, screen_name) VALUES ('[email protected]', 'password', CURRENT_DATE(), TRUE, 'user11'); 
INSERT INTO quality.tb_account_roles (account_id, role_id) VALUES (LAST_INSERT_ID(), 1); 
COMMIT 
    (conn:2) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO quality.tb_account (email, password, registration_date, active, scre' at line 2 
Query is : BEGIN; 
INSERT INTO quality.tb_account (email, password, registration_date, active, screen_name) VALUES ('[email protected]', 'password', CURRENT_DATE(), TRUE, 'user11'); 
INSERT INTO quality.tb_account_roles (account_id, role_id) VALUES (LAST_INSERT_ID(), 1); 
COMMIT 
    org.mariadb.jdbc.internal.util.dao.QueryException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO quality.tb_account (email, password, registration_date, active, scre' at line 2 
Query is : BEGIN; 
INSERT INTO quality.tb_account (email, password, registration_date, active, screen_name) VALUES ('[email protected]', 'password', CURRENT_DATE(), TRUE, 'user11'); 
INSERT INTO quality.tb_account_roles (account_id, role_id) VALUES (LAST_INSERT_ID(), 1); 
COMMIT 

私が間違って何をやっています?それぞれのクエリは単独で動作するが、一緒に動作するのはなぜですか?

答えて

0

それぞれのSQL文を単独で発行する必要があります。連結しないでください。

「... INSERT ...」の近くにあることに注意してください。それ以降はものを見つけるのが好きではなかった。

+0

助けてくれてありがとう! – rojoherrero

関連する問題