SPCall getInParamValue

I am trying to access the value of an input parameter of an SProcCall object. I see in the documentation there are methods for getting result sets, update counts, return values, and out param values. Is there no method for getting the value of an input parameter? The use case is, I use a custom method to build the SProcCall before passing it back. The call can be passed to and modified by other methods, so I need to check what a value is that was registered in another method.

For the time being I am converting the call to a literal string and using regex to grab the value of the parameter. I hope there is a better way to do it than this.

strCall = str(call)
import re
pattern = r"ArgKey\[name=myInputParam\]=ArgValue\[type=\d+,value=([^,]*),"
match = re.search(pattern, strCall)
if match:
    myInputParam = match.group(1)
    if not myInputParam:
    	myInputParam = ','

So are you wanting to get the value before you actually send it off to be executed?

Hi @Benjamin_Furlani.

The value can be retrieved before or after I execute the call. I handle execution of the call in the final method which is also where I am trying to retrieve the value of the input parameter.

If you have control over the other scripts why can't you return the input values?

You could return them in a dict format before you execute and then pass in the call. something like {"call":"mySP @param1=1","params":{"param1":1}}

You could also technically do an output parameter but that seems like a waste when you have access to it in Ignition already.

Edit:
Depending on what your intensions are with the parameter you could also just do the check inside of where it is getting passed into the call to the stored procedure.

@Benjamin_Furlani

I considered doing that, but it looks silly to me to return an additional value when I already have a copy of it in my first return value. I think that's just as unclean as using regex to parse the value out of the string literal of the call. I appreciate the suggestion though, it is a good alternative to consider if nothing else exists.

Just a note, you don't need to @ me when you click reply.

It seems unintuitive to me that your checking the value after it's been determined to be in the stored procedure call. If you're logging that value then just do that in the stored procedure. I still recommend doing any checks of inputs inside of where you are generating the call.

Can you explain why you need to the input outside of after it has been called?

The call object should have a _getParams() method; I don't think the leading underscore actually enforces anything in Jython. That will return a map/dictionary keyed by not-quite-strings, which I don't think you can actually construct (so no O(1) lookup) but you could still just iterate over all the entries and check the attributes of the keys individually.

1 Like

call.getParams() throws an error, but call._getParams() returns a dictionary of ArgKey and ArgValue.

I don't know how to access the values inside of ArgKey and ArgValue, so I'm back to parsing strings. But really what you're saying is that it was never intended that users would retrieve input values from calls, so while it can be "hacked" there is no simple way to do it.

I appreciate the responses from everyone.

ArgKey instances have a public contract documented in their javadoc:

Ditto SProcArg: