Do you have a default gateway scoped project set up?
Named queries are scoped to a project, and if the project isn't identified here then the tag event script would be unable to use the resource.
To simplify, use a simple runPrepUpdate on the tag event script.
if currentValue.value == 1: # rising
system.db.runPrepUpdate(query, [], "DBConnName")
