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 5844215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:15:39+00:00 2026-05-22T12:15:39+00:00

I know this has been asked before but those solutions seems not to work

  • 0

I know this has been asked before but those solutions seems not to work with me.

I’m currently trying to do this:

  1. Build a “CREATE PROCEDURE” script string for oracle
  2. Create a SQL Command using enterprise library 5.0 and pass this string as parameter
  3. Have the procedure saved in the oracle database

So point #3 seems to work so far, if I open SQL Developer and expand the procedure tree list then I can actually see the procedure but with the red cross circle which means it has compiler errors though running this same code, which is pretty small, in a SQL Developer query window works fine and compiles it. I’m not sure in SQL Developer does something under the hood because running that “CREATE PROCEDURE” script throws no error whatsoever, I can then see and execute the procedure but not so doing it from C#.

I read in the link posted in the beginning of this that I should call IDBCommand.Prepare(), but that method is only relevant if your SQLCommand.CommandType is of type StoredProcedure and since I’m not calling a procedure actually but running pure sql to CREATE the procedure then this wouldn’t work, nevertheless, I, just for the sake of testing, created a new command which I assigned to StoredProcedure and then called the Prepare() method on that command, finally the ExecuteNonQuery() method which throws an exception of the object (the stored procedure) not being available which makes sense since it hasn’t been compiled…

So, I wonder if anybody actually knows how you can create a procedure and compile it from C#, we are currently using enterprise library but I wouldn’t mind “hard coding” something directly to the oracle provider as long as it works.

Btw, before telling me that creating a procedure from the code is a bad practice I tell you that unfortunely this is a customer’s project and we had no decisions on the making, actually we are trying to migrate the thing from SQL Server to Oracle.

  • 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-22T12:15:40+00:00Added an answer on May 22, 2026 at 12:15 pm

    I’m a bit rusty and have no Oracle access right now, but I think I know what your’e asking for. You want to use the ADO.NET OracleCommand class and the Oracle EXECUTE IMMEDIATE statement. Something like this:

            OracleConnection conn = new OracleConnection("Data Source=something; user id=something; Password=something;");
            conn.Open();
            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;
            command.CommandText = "execute immediate 'create or replace procedure [...you know this part...]' ";
            command.Connection = conn;
            command.ExecuteNonQuery();
            conn.Close();
        }
    

    That should work. But note that I’ve always used ODP.NET (Oracle’s own data provider) instead of the stock ADO.NET one, so there may be some slight differences if you’re just using the stock library.

    As Pete suggested you could also use dynamic SQL to the same effect. You’d pass the whole CREATE PROCEDURE statement as a parameter to an existing stored procedure which then calls EXECUTE IMMEDIATE for you. However I don’t believe that you have to do it that way. The above should work if you want to keep it minimal.

    One other thing. I don’t know why this would be happening, but if Oracle is telling you the procedure is invalid even though you know it’s fine, try executing

    EXECUTE IMMEDIATE ALTER PROCEDURE schemaname.procedurename COMPILE;
    

    I’ve often found Oracle to be a bit fragile with regards to invalidating objects unnecessarily.

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

Sidebar

Related Questions

I know this question has been asked before but the solutions did not work
I know this question has been asked before but the other solutions didn't work
I know this specific question has been asked before , but I am not
I know this question has been asked here before, but I don't think those
I know this has been asked before, but it just doesn't work for me.
I know this has been asked before but there is really not a clear
I know this has been asked before , but I don't think these solutions
I know this type of question has been asked before, but I could not
Ok, I know this has been asked before but after searching I couldn't find
I know this has been asked before, but I've found a different way to

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.