INSERT query show error

Hi,

We have an INSERT query, and after executing it, we try to refresh the table data. However, the INSERT query always shows an error, even though the new record is successfully added to the table. Because of this error, the subsequent code does not execute.

# If both not found, insert new record
		if not userExists and not badgeExists:
		    system.db.runNamedQuery(
		        "gestione_produzione/SystemMgmt/InsertOperatorUser",
		        {
		            "USER": userValue,
		            "FIRSTNAME": firstName,
		            "LASTNAME": lastName,
		            "BADGECODE": badgeValue,
		            "CREATEDDATETIME": system.date.now(),
		            "ACTIVE": True,
		            "LASTLOGIN":system.date.now(),
		            "MODIFIEDDATETIME":system.date.now()
		        }
		    )
		    
		    msg = "Il record inserito"
		    iconPath = "material/warning"
		    # Open popup
		    system.perspective.openPopup(
				"BP_PopupConfirm_operator",
				view="templates/PopupInfo",
				params={
					"message": msg,
					"icon": iconPath					
				},
				title="Conferma",
				modal=True,
				draggable=False,
				resizable=False,
				showCloseIcon=True
			)		    
		    table = self.parent.parent.getChild("Table_0")		    
		    table.refreshBinding("props.data")

The error return by insert query is this:

Error running action 'component.onActionPerformed' on pages/Operator_mgmt@D/root/FlexContainer_1/FlexContainer/Button: Traceback (most recent call last): File "<function:runAction>", line 32, in runAction at com.inductiveautomation.ignition.gateway.db.namedquery.NamedQueryExecutor$NamedQueryInstance.execute(NamedQueryExecutor.java:407) at com.inductiveautomation.ignition.gateway.db.namedquery.NamedQueryExecutor.execute(NamedQueryExecutor.java:173) at com.inductiveautomation.ignition.gateway.db.namedquery.GatewayNamedQueryManager.execute(GatewayNamedQueryManager.java:95) at com.inductiveautomation.ignition.common.db.namedquery.SecuredNamedQueryManager.execute(SecuredNamedQueryManager.java:78) at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:419) at jdk.internal.reflect.GeneratedMethodAccessor24.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.Exception: java.lang.Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.

What is the code in the button?
/root/FlexContainer_1/FlexContainer/Button:

File "<function:runAction>", line 32,
What's on line 32?

SQLServerException: The statement did not return a result set.
Are you looking for a result set?

Change the query type of your named query to update

2 Likes

Thanks a lot you all of you for quick support…

Hi, Pascal.
What was the clue in the error message that I missed?

You quoted it. Updates do not return result sets.

1 Like