我正在尝试向 MySQL 提交一个 sql 事务,但我让自己通过了MySQLSyntaxErrorException
.
我正在使用的代码是:
implicit connection =>
SQL("""
start transaction;
insert into projects(id_user, name, description) values({idUser}, {name}, {description});
set @last_id = last_insert_id();
insert into assigned(id_user, id_project) values({idUser}, @last_id);
commit;
""")
.on('idUser -> idUser,
'name -> project.name,
'description -> project.description
).execute()
我得到的例外:
[MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into projects(id_user, name, description) values(1, 'First inserted proje' at line 1]
我开始认为我根本无法使用 Anorm 执行此类语句。