system.db.runNamedQuery database parameter required

When calling system.db.runNamedQuery I am receiving a “Required parameter “database” not provided.”

The Named Query is set to receive the database parameter and I am passing that parameter as the first argument in the param dictionary. Does it have to be signified differently?

I’ve tried setting the scope to the Client Project as well as leaving scope blank (thinking the default scope is the project. Running Version 8.0.7

params = {“param1”:connectiondb,“param2”:var1,“param3”:var2,“param4”:var3, “param5”:var4}
system.db.runNamedQuery(“NamedQuery”,params)

No, it is not passed in the parameters. It is the first argument to the function when called from gateway scope:

https://docs.inductiveautomation.com/display/DOC80/system.db.runNamedQuery

Whoops, you’re asking about the database, not the project. Though that might be the answer: default database is determined from the project.

I appreciate the quick reply. In my case I am not using a default database since this project will be used with several databases. I have a tag value for the database connection for the client to set. Can that connection not be passed to a named query?

Parameter names passed in should match parameter names in the named query, and the database parameter is called ‘database’. So it would look something more like this, but the parameters named param# need to match what you’ve set in the named query creator.

params = {“database”:connectiondb,“param2”:var1,“param3”:var2,“param4”:var3, “param5”:var4}
system.db.runNamedQuery(“NamedQuery”,params)
1 Like

Awesome. Next time I’ll try the most obvious thing I can think of… Hope IA can update the Documentation to mention that?
Thank you.

1 Like