Need help with error code and named queries

Hello everyone,

I have a named query I am trying to run and I am getting an error I can’t seem to find the answer to. I have mediocre ignition experience and I haven’t used it in 8 months so I am a bit rusty here and need some help. Below is my query, error code and code I am running:

ERROR CODE FULL

Traceback (most recent call last):
File “event:actionPerformed”, line 5, in
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1434)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)
at com.inductiveautomation.ignition.client.script.ClientDBUtilities.runNamedQuery(ClientDBUtilities.java:105)
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)
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘P1551370-07-D:STRR220710G0AK9’ into type: interface java.util.Map

at org.python.core.Py.JavaError(Py.java:552)
at org.python.core.Py.JavaError(Py.java:543)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:539)
at org.python.core.PyObject.__call__(PyObject.java:497)
at org.python.core.PyObject.__call__(PyObject.java:501)
at org.python.pycode._pyx37.f$0(<event:actionPerformed>:5)
at org.python.pycode._pyx37.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy63.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.ClassCastException: Cannot coerce value ‘P1551370-07-D:STRR220710G0AK9’ into type: interface java.util.Map
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1434)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)
at com.inductiveautomation.ignition.client.script.ClientDBUtilities.runNamedQuery(ClientDBUtilities.java:105)
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)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188)
… 48 more

Ignition v8.1.7 (b2021060314)
Java: Azul Systems, Inc. 11.0.11

QUERY FULL

SELECT Cell_ID, Pre_EFill_Weight, Preweigh_Lower_Spec_Okay, EFill_Number, Fill_Head, Boat_Num, Boat_Position, Weight_Post_EFill, Weight_Delta, Date

FROM (SELECT component_id as Cell_ID, From_UNIXTIME(observed_at_seconds) as Weigh_timestamp_PST, location_name as EFill_Number, event_dt as Date

FROM ion-rpt.roadrunner_ion_observations_taskresults

WHERE component_id = :Component_ID
AND location_name LIKE ‘cm2_49%’
) as main_info

LEFT JOIN(SELECT component_id, submitted_value AS Boat_Position
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘preweigh_data’
AND parameter_name = ‘cell_boat_position’) as BoatPos
ON main_info.Cell_ID = BoatPos.component_id

LEFT JOIN(SELECT component_id, submitted_value AS Fill_Head
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘electrolyte_fill_cell’
AND parameter_name = ‘fill_head’) as FillHead
ON main_info.Cell_ID = FillHead.component_id

LEFT JOIN(SELECT component_id, submitted_value AS Boat_Num
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘preweigh_data’
AND parameter_name = ‘boat_id’) as BoatNum
ON main_info.Cell_ID = BoatNum.component_id

LEFT JOIN(SELECT component_id, submitted_value as Pre_EFill_Weight
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘preweigh_data’
AND parameter_name = ‘weight_pre_efill’) as PreFill
ON main_info.Cell_ID = PreFill.component_id

LEFT JOIN(SELECT component_id, submitted_value as Preweigh_Lower_Spec_Okay
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘preweigh_data’
AND parameter_name = ‘preweigh_lower_spec_okay’) as PreweighLowerSpec
ON main_info.Cell_ID = PreWeighLowerSpec.component_id

LEFT JOIN(SELECT component_id, submitted_value as Weight_Post_EFill
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘postweigh_filled_cell’
AND parameter_name = ‘weight_post_efill’) as WeightPostFill
ON main_info.Cell_ID = WeightPostFill.component_id

LEFT JOIN(SELECT component_id, submitted_value as Weight_Delta
FROM ion-rpt.roadrunner_ion_observations_taskresults
WHERE location_name like ‘%cm2_49%’
AND task_name = ‘postweigh_filled_cell’
AND parameter_name = ‘weight_delta_efill’) as WeightDelta
ON main_info.Cell_ID = WeightDelta.component_id

LIMIT 1

CODE

table = event.source.parent.getComponent(‘Power Table’).data
componentID = event.source.parent.getComponent(‘Text Field’).text

system.db.run(“TMuckley_Test/ScanSearch”, componentID)

This is your problem. When you call system.db.runNamedQuery() you have to supply the parameters as a dictionary.

system.db.runNamedQuery("TMuckley_Test/ScanSearch", {"Component_ID":componentID})
4 Likes

Oh my god I am an idiot. I even told myself earlier this evening to remember to do this. It’s been a long night LOL. Thank you very much sir. I really appreciate it!!

4 Likes