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

  • SEARCH
  • Home
  • 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 6228811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:27:08+00:00 2026-05-24T09:27:08+00:00

Somehow or the other, I learned that I can simply pass in parameters into

  • 0

Somehow or the other, I learned that I can simply pass in parameters into an Oracle stored proc and it would be able to convert the parameters into the appropriate type. Well I am running into issues dealing with that. I am getting an “ORA-00900: invalid SQL statement” returned to me… I am guessing it is because I am attempting to pass in strings… That is what I read somewhere anyway…
“http://www.dba-oracle.com/sf_ora_00900_invalid_sql_statement.htm”

What is the technique for inputing Oracle parameters into a stored proc and then executing that stored proc using .net Variables? Will I have to convert the .net strings into ODP data types? I hope not…

Here is what my code generall does…

    XmlAttribute xAttribute;
        using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["ACODBConnectionString"].ConnectionString))
        {

            using (OracleCommand cmd = new OracleCommand(sProc, conn))
            {
                int i = 0;
                foreach (string path in paths)
                {
                    string OracleParam;
                    xAttribute = AcoXMLDoc.SelectSingleNode(string.Format("//dataTemplateSpecification/templates/template/elements/element[@name='{0}']", path)).Attributes["value"];
                    if ((xAttribute.Value == null))
                    {
                        OracleParam = "";
                        cmd.Parameters.Add(colName[i], OracleParam);
                    }
                    else
                    {
                        OracleParam = xAttribute.Value;
                        cmd.Parameters.Add(colName[i], OracleParam);
                    }
                    i++;
                }
                conn.Open();
                outcome = cmd.ExecuteNonQuery();
            }
        }

As you can see, I am pulling the values out of an XML document so naturally the values are going to be strings… It is going to suck so much a$$ if I have to figure out how to change the strings into the appropriate data type…

  • 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-05-24T09:27:10+00:00Added an answer on May 24, 2026 at 9:27 am

    The cmd.Parameters.Add() expects an object that is a parameter (not the value of the parameter)

    so this is doable, with a few caveats but here is a test case:


    set up the Oracle bit:

    create table testParam(aa number, bb varchar2(50) , cc date) 
    /
    create or replace procedure testProcParam(
                      p_aa IN TESTPARAM.AA%TYPE , --usage of tableName.ColumnName%Type has this "scoped" to the table.column AA (here it is number)
                      p_BB IN TESTPARAM.BB%TYPE , --The usage of TYPE here has it defined as VARCHAR2
                      p_CC IN TESTPARAM.CC%TYPE  --this is DATE
    ) is
    BEGIN
        INSERT INTO testParam (AA, BB, CC) VALUES(P_AA, P_BB, P_CC);
    END testProcParam ;
    /
    

    now for the .net bit:

      OracleConnection con = Connect(constr);
    
      // Set the command
      OracleCommand cmd = new OracleCommand("testProcParam", con);
      cmd.CommandType   = CommandType.StoredProcedure;
      cmd.BindByName = false; /*mark this false to bind by position*/
    
      string AA = "123456" ;
      OracleParameter oparamAA  = new OracleParameter() ;
      oparamAA.Value = AA;
      cmd.Parameters.Add(oparamAA);
    
      string BB = "abcdefghijklmnopqrst" ;
      OracleParameter oparamBB  = new OracleParameter() ;
      oparamBB.Value = BB;      
      cmd.Parameters.Add(oparamBB);
    
      string CC = "01-AUG-11" ; /*we rely on the nls date parameter to 'cast' this*/
      OracleParameter oparamCC  = new OracleParameter() ;
      oparamCC.Value = CC;      
      cmd.Parameters.Add(oparamCC);      
    
      cmd.ExecuteNonQuery ();
    
      con.Close();
      con.Dispose();   
    

    Now things to take note of:

    1. Notice how I create the parameter and assign the “string” value to it (http://download.oracle.com/docs/cd/B19306_01/win.102/b14307/OracleParameterClass.htm#i1011127 you will see that the constructors are either no dbtype or you must explicitly state it, this gets around that)
    2. if the parameters are not named (ie you are relying on ordinal position) you must “cmd.BindByName = false;”
    3. For dates, the NLS format comes into play here (thus you are opening yourself up to date issues if you change date formats etc)

    then you will have your data:

    SELECT * FROM testParam;
    
    AA                     BB                                                 CC                        
    ---------------------- -------------------------------------------------- ------------------------- 
    123456                 abcdefghijklmnopqrst                               01/08/11 00:00:00  
    
    /* --now to clean up
    DROP procedure testProcParam ;
    DROP table testParam ;
    */
    


    EDIT

    Per your comment; in the parameters in PL/SQL when you use

    tableName.ColumnName%Type

    you are actually just tying that datatype to the column’s data type in the table (this allows the column to be changed and it won’t break the package).

    for the example I provided:

                      p_aa IN TESTPARAM.AA%TYPE , 
                      p_BB IN TESTPARAM.BB%TYPE , 
                      p_CC IN TESTPARAM.CC%TYPE  
    

    is the same as

                      p_aa IN NUMBER, 
                      p_BB IN VARCHAR2  , 
                      p_CC IN DATE
    

    Not sure of an ‘anonymous/generic datatype’ that you can pass in

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I convert somehow .blend and .x3d and other 3D file sdirectly online on
Can I get somehow(from a database or other source) a percentage of the phones
Big applications contains lots of objects that are somehow connected to each other. There
I'm curious if I can somehow make the Widget.Wrapper shape (or other wrappers) alternateable,
This is probably just me being stupid somehow or the other, but I am
Somehow I had the impression that ASP.Net differentiates URLs based on the number of
Somehow, using linq I can't test it with this CUF field in the beginning:
I have an ASP.NET web app that places several string data into an object
Edit: Ok so I learned that I guess I need an distributed source control,
Today, during some other somehow related work, came across my mind the following question:

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.