Named Query Transaction

Hello, I have a problem with the transaction of a named query, this is my code in perspective:

txId1 = system.db.beginNamedQueryTransaction(project="ferprueba", datasource="JasmineDB", timeout=5000)
system.db.runNamedQuery("InsertReport", {"AREA": area, "NOTE": note, "PET": pet}, tx = txId1)

This is the error:
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 21, in runAction File "", line 21, in runAction at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.lambda$runNamedQuery$0( at java.base/java.util.Optional.orElseThrow(Unknown Source) at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery( at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) com.inductiveautomation.ignition.common.project.ProjectNotFoundException: com.inductiveautomation.ignition.common.project.ProjectNotFoundException: project not found: InsertReport

You’re calling system.db.runNamedQuery() in a Gateway Scope, so you must provide a project name. The error is stating that it can’t find the project. I suspect that you have left out the project name and InsertReport is the name of your query.

1 Like

Thank you. I had to add the project name to the system.db.runNamedQuery function:
system.db.runNamedQuery("ferprueba", "InsertReport", {"AREA": area, "NOTE": note, "PET": pet}, tx = txId1)

Welcome to the forum, Fernando. For future posts please see Wiki - how to post code on this forum.