2

Situation:
I'm trying to run a stored procedure that has an output parameter, which I need to catch.
I use C# 3.5 and the OracleClient with an OleDbConnection.

Research:
I've been looking around for other ways, but as far as I can tell I'm doing it correct. Microsoft support and various other forums.

Problem:
When I do the cmd.ExecuteNonQuery() it just gets stuck. No error or anything, it just stops there and holds the Thread.
When I try via OleDbDataReader or the Scalar it's nothing better.
If I change the CommandText (remove package name) it gives error that it can't find the stored procedure, so I know that is correct at least.

Code:
Oracle:

PROCEDURE deleteThemakaart
(an_seqthemakaart IN NUMBER, an_retval OUT NUMBER)
....

C#:

double InputValue = 777;
try
{
    OleDbConnection con = new OleDbConnection(...);
    con.Open();

    OleDbCommand cmd = new OleDbCommand()
    {
        CommandText = "thema.pckg_themakaarten.deleteThemakaart",
        Connection = con,
        CommandType = CommandType.StoredProcedure,
    };

    OleDbParameter input = cmd.Parameters.Add("an_seqthemakaart", OleDbType.Double);
    OleDbParameter output = cmd.Parameters.Add("an_retval", OleDbType.Double);

    input.Direction = ParameterDirection.Input;
    output.Direction = ParameterDirection.Output;

    input.Value = InputValue;

    cmd.ExecuteNonQuery();

    return (double)output.Value;
}
catch (Exception ex)
{
    ...
}
finally
{
    con.Close();
}

Any help is very welcome :)

Edit: some code is below in comment, but hasn't gotten me any further so far :(

Greetings

7
  • Have you tried calling the procedure directly, i.e. with a PL/SQL script? So just to exclude the possibility that the procedure itself doesn't return. Commented Jun 27, 2011 at 9:58
  • How about setting the direction in Add itself ? Commented Jun 27, 2011 at 9:58
  • If I call the stored procedure in SqlNavigator it works perfectly. And I can't set the Direction directly in Add can I? I could add .Direction = ... but then it won't return the OleDbParameter. Commented Jun 27, 2011 at 10:01
  • Have you tried with a different type for the parameters instead of OleDbType.Double? The identifier should rather be an Integer (or BigInt) I guess. Commented Jun 27, 2011 at 10:17
  • I used Double because when I used an XSD scheme to get data it converted it to Doubles. But even when I try with Decimal/Integer/BigInt it didn't work as well. Commented Jun 27, 2011 at 10:46

1 Answer 1

2

I found the trouble maker... one of the tables that the procedure used was locked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.