Two issues:
-
When running a tag event, the script is outside any normal project scope, and therefore has no default database. The optional parameter to
system.db.runQuery
for the database is not optional in this situation. -
Running any kind of database query, unless it always executes extremely quickly (single-digit milliseconds), is inappropriate in tag event scripts. Use a gateway tag change script instead (in the project, subscribed to the reference tag, not on the reference tag).
{ Failure to follow the fast-execution rule for tag events can crush your entire system. }