hi
I am using stored procedure to send data from Ignition to other system. I didn't get my head around how to capture the feedback from the executed stored procedure - there must be a way -right? Stored procedure itself i was told to use does not provide any value and from what i read in docs SProcCall also does not provide any feedback.
So if stored procedure itself does not provide any return value is using it like fire and forget ?
My code wrapped in the function looks following :
i agree it sounds strange but i was given this stored procedure and i was told that it does not return anything for legacy code purposes. So i guess my sanity check has passed and all i can do is use try: except wrapper which would catch lack of parameter passed.
Stored procedures always return a value. If no return statement is provided then the default return is 0.
Due to the way that system.db.execSProcCall() works you must register a return param. However, much like system.tag.writeBlocking() and similar functions providing a return value, that doesn't mean you have to use it.
The quirkiness of SProcCall and its helpers is why I have moved away from SP when Ignition is involved, and if I want to execute a SP, I will just create a Named Query to execute it and move on.
Thanks for help. I read somewhere in docs that preferred way to call stored procedure is with system.db.execSProcCall(). Can you please elaborate on the benefit of using named query - what steps are needed and what benefits are gained doing this?
And...You're done, much simpler. It's truly fire and forget in this case as you're unconcerned with the return value, though it will also work with stored procedures that return result sets.
You get all of the advantages of a named query, and you don't run into the eccentricities that come with creating a SPCall. Back in the days prior to named queries this was the only way to call stored procedures, IMO named queries have made the method mostly obsolete.
All of that out of the way, unless you're doing some really advanced things in the stored procedure that isn't handled so well by the JDBC driver, and those kinds of things do exist, or you have other third party software that is also using the stored procedure, I would recommend just putting the SQL directly in the named query itself. Makes things much more manageable IMO.
You answered my question really well so many thanks. I am curious type - any chance you give me a gist on :
unless you're doing some really advanced things in the stored procedure that isn't handled so well by the JDBC driver, and those kinds of things do exist,
What sort of fancy things i need to be aware of - i am working mostly with Microsoft SQL server - is it worth reading JDBC specification for microsoft server jdbc driver if time permits?
Batching operations, Cursors, lots of work with creation of and dropping of temporary tables. Anything where the query optimization is really important is most likely going to be better handled in a Stored Procedure.
For most things that you're going to do with Ignition, Named Queries will work just fine. Its the types of things that you find your self googling "How to do X" with a purpose other than a reminder of the needed syntax.