I have a button on perspective who fire a named query.
The named query execute a stored procedure.
The stored procedure consist of an update and an insert in a log table.
It works but I have the following warning in the gateway log.
Error running action 'component.onActionPerformed' on partials/DetailsRun@C$0:0/root/RunPresent/Buttons/BtnFinDeRun: Traceback (most recent call last): File "<function:runAction>", line 2, 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:92) at com.inductiveautomation.ignition.common.db.namedquery.SecuredNamedQueryManager.execute(SecuredNamedQueryManager.java:78) at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:418) at jdk.internal.reflect.GeneratedMethodAccessor44.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: java.sql.SQLException: La sous-requête a retourné plusieurs valeurs. Cela n'est pas autorisé quand la sous-requête suit =, !=, <, <= , >, >= ou quand elle est utilisée en tant qu'expression.
If I execute the same stored procedure in SQL Management Studio I don't get any error.
I don't understand the problem. Anyone as an idea ?
The subquery returned multiple values.
This is not allowed when the subquery follows
= , != , < , <= , > , >= or when used as an expression.
Can you think of any reason the subquery is returning only one record in SQL Management Studio but returns multiples when run from an Ignition named query?
I've never had to use a stored procedure in an Ignition application so I might not be able to help much. I looked through the forum at related posts and I wonder if you should set the named query Query Type to "Query" rather than "Update". It should be a simple test.
[Edit] I thought the SQL script was in the stored procedure. It looks like it was in the named query so my answer wasn't relevant.
That isn't a SQL query. It is a SQL script. Java's vanilla JDBC doesn't support SQL scripts, just single SQL statements.
Because of this, testing in SSMS is not valid for JDBC in Ignition. Some drivers will do it (with caveats for named queries), but if you are actually putting @variable or BEGIN and END, or any similar structures in Ignition, you are on your own.
Also note that stored procedures must have a consistent return. Either a single query status (normally a row count for an update/insert/delete) or a single dataset. If your SP logic is running an insert then a final SELECT, that will make two returns.