How do I run multiple queries for a delete:
@Delete(
"""DELETE FROM punch_attachment WHERE tablename = '${tableName}' AND recordid = #{id};
DELETE FROM punch_tagged_item WHERE table_name = '${tableName}' AND record_id = #{id};
DELETE FROM ${tableName} WHERE id = #{id};"""
)
This gives a syntax error
So does this:
@Delete(value = [
"DELETE FROM punch_attachment WHERE tablename = '${tableName}' AND recordid = #{id};",
"DELETE FROM punch_tagged_item WHERE table_name = '${tableName}' AND record_id = #{id};",
"DELETE FROM ${tableName} WHERE id = #{id};"
]
)
override fun delete(id: Long): Int
Basically, I need my dao to do all 3 of these when deleting an item. How do I do it? Here's the error:
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 'DELETE FROM punch_tagged_item WHERE table_name = 'punch_item' AND record_id = 11' at line 1
If I paste this error into a query console, it works fine. There is not a syntax error here. It has to do with the multiple queries...
I do not want to create a service to compose this, nor do I want a DB procedure to do this.
allowMultiQueries?