Im having trouble doing this batch operations like this.
val params = Seq(Seq[NamedParameter]("valueA" -> 1, "valueB" -> 2))
BatchSql(SQL(
"""
INSERT INTO tableA ( valueA ) VALUES ( {valueA} );
INSERT INTO tableB ( tableAId, valueB ) VALUES ( LAST_INSERT_ID(), {valueB});
""".stripMargin), params).execute()
With tables like...
CREATE TABLE tableA
(
id int AUTO_INCREMENT PRIMARY KEY,
valueA int
);
CREATE TABLE tableB
(
id int AUTO_INCREMENT PRIMARY KEY
tableAId int,
valueA int,
FOREIGN KEY (tableAId) REFERENCES tableA (id),
);
I get this exception, just complaining about line 2.
BatchUpdateException: 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 tableB ( tableAid, valueA' at line 1]]
Thanks