I need to call a Stored Procedure in python.
The wrapper function accepts n number of parameters.
Based on the parameter list, I need to quote or unquote the arguments. I also need to send a null parameter.
How can I iterate through the function argument and build the SQL string?
for eg. the stored proc call looks like this – SP_TEST(‘chrA’,intB,chrC)
def execSp(a,b,c,d):
<iterate through params and build param list>
#If the parameter c is null the SQL should be built as below
SQL="exec SP_TEST('a',b,Null)";
I tried using locals() however it returns an unordered list
Am new to python so any leads will be of great help.
The following does exactly what you want. It starts by initializing the list AV to all NULL, then iterates of the number of arguments supplied, and replaces them appropriately to form the query string that you wanted. The
SQL =string adds quotes to the first argument only. Did I understand correctly what you were trying to do?When I run this, I get