I am running a SQL query that works well when copied-and-pasted in H2 or MySQL, but fails in Anorm with a cryptic error message: 'id' not found, available columns: SCOPE_IDENTITY()
:
[debug] c.j.b.PreparedStatementHandle -
INSERT INTO projects (person_id,name,code_name,isControl,toAnalyze)
VALUES (111,'asdf','asdf',1,1)
[info] anorm.AnormException: 'id' not found, available columns: SCOPE_IDENTITY(), SCOPE_IDENTITY()
N.B. There is a column id
in this table - primary key with auto-increment -, not sure if it is related though.
What does that mean?
I was actually due to me querying
SQL"...".executeInsert(parser.*)
with an ill-defined parser instead of
SQL"...".executeInsert()
SCOPE_IDENTITY refers to the ids of the inserted rows, and passing a parser to the executeInsert
method makes it return a list of custom objects (possessing an id
field, apparently) instead of a list of Ints.