Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:36:33+00:00 2026-06-18T06:36:33+00:00

I need to call a Stored Procedure in python. The wrapper function accepts n

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:36:34+00:00Added an answer on June 18, 2026 at 6:36 am

    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?

    def execSp(*args):
      AV = []
      SQL = "exec SP_TEST(";
      for ii in range(0,4) :
        AV.append("NULL");
      ii = 0;
    
      for a in args:
        AV[ii] = str(a);
        ii+=1;
    
      SQL = SQL + "\'" + AV[0] + "\'," + AV[1] + "," + AV[2] + "," + AV[3] + ")";
      print SQL
    
    execSp("hello", 1, 2, 3);
    execSp("hi", 2, 3);
    

    When I run this, I get

    exec SP_TEST('hello',1,2,3)
    exec SP_TEST('hi',2,3,NULL)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to call a stored procedure in oracle. One of the parameters is
it need a way to call function whose name is stored in a string
Need to call a filter function on some options based on a radio selected
I need to call a JS function with a C# parameter. This is inside
I need to call a stored procedure using JPA and found this article: http://www.oracle.com/technology/pub/articles/vasiliev-jpql.html
Please help me with the following scenario I need to call a Stored Procedure
i need to call sqlcmd from stored procedure to export table to text file?
I need to call a stored procedure during my report to insert values into
I have one store procedure that will need to call a second stored procedure
I need to call a stored procedure and pass arguments in from Powershell. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.