How to correctly execute a query that contains a procedure and has no return in Objectscript/Intersystems IRIS

306 views Asked by At

I am trying to execute a stored procedure from my Operation, the way I have the most satisfatory result was by the following call:

Set tResult = ##Class(EnsLib.SQL.GatewayResultSet).%New()
Set tQuery = "EXEC MY_PROC @name = 'Jhon', @profession = 'carpenter'"
Set tSC = ..Adapter.ExecuteQuery(.tResult, tQuery)

The procedure is executed, (it removes a registry from an ODSE database and has no return by default) but I get an error like

"Error #5023 Remote Gateway Error. The statement did not return a resultset."

And my operation stops.

I even tried the method ExecuteProcedure without success.

Can anyone help me on that :)

Ps. I'm new on this stack, and a junior at all. D:

Thanks in advance.

1

There are 1 answers

0
Luiz Antonio Negrinho On

I've found my problem, I was calling the wrong method for this occasion. The right method to call a procedure or a query with no return is ExecuteUpdate() instead of ExecuteQuery(). This method returns only the number of rows affected and receive our procedure command. So the example would be like:

Set tQuery = "EXEC MY_PROC @name = 'Jhon', @profession = 'carpenter'"
Set tSC = ..Adapter.ExecuteUpdate(.tNumberOfRowsAffected, tQuery)

The official documentation of Objectscript can be like a dark cave sometimes.