I have the following script in the global scripts library under the script name ‘zTest’. I am attempting to run this code in two different expressions using runScript('shared.zTest.myFunc',0)
and runScript('shared.zTest.myString',0)
. The expressions define parameters for a report.
def myFunc():
x = system.db.runQuery('SELECT FormType FROM PMFormClass')
x = [i[0] for i in x]
x = [[a] for a in x]
y = system.dataset.toDataSet(['Form Type'], x)
return y
def myString():
return 'Generic String'
The call to myString() successfully outputs the desired string, but myFunc() does not, yielding this error:
Using a button in Vision Client I can successfully take the return from myFunc() and pass it directly into a table as a dataset, so I believe the SQL query and the code in myFunc() is correct.
After some troubleshooting it appears that runScript() won’t run anything with a SQL query in it. Does anyone have any ideas why this might be?
I know for this very simple case it would be better to use the reporting module’s SQL capability, but this is the very boiled down version of the script that will eventually be in production. There are also a variety of reasons I would like to use the script method if it is possible.
Any ideas would be greatly appreciated.
Ignition Version: 7.9.6
Java Version (Gateway): 1.8.0_151-b12
Java Version (PC): 8.0.1510.12