tags:

views:

204

answers:

2

Ok, this seems simple but I can't find a solution to save my life. I am trying to do a very simple INSERT query on an Oracle DB. I can log into the DB in TOAD with the same credentials as I use in the code and run the INSERT with no problem, so as near as I can tell there are no permissions issues with the credentials and the query itself is syntacticly correct. When I try to run the below code, it just hangs. No errors or anything. I can see the session pop up in TOAD so as far as I can tell the code establishes the connection with no problem. Here is the code:

        String connStr = "Data Source=DB;User id=<USER>;Password=<PASSWORD>;";
        String query = "INSERT INTO table (fields) VALUES (values)";

        OracleConnection conn = new OracleConnection(connStr);
        conn.Open();
        OracleCommand cmd = conn.CreateCommand();
        cmd.CommandText = query;
        cmd.CommandType = CommandType.Text;
        cmd.ExecuteNonQuery();
        conn.Close();
        conn.Dispose();

I have also tried using an ADO connection and got the same result. Any ideas are appreciated.

A: 

Have you tried wrapping it in a transaction and explicitly committing after the insert? IIRC, Oracle's default semantics are very transaction-oriented, unlike SQL Server's.

Harper Shelby
I will try this. If you have code that would help. Regardless I'll poke around the web and see if I can find an example.
EBGreen
+3  A: 

Have you committed or rolled back the transaction in Toad? Your application could be waiting on a lock held by your session created by Toad.

Mark Roddy
I have not but I will try that now.
EBGreen
Ding! Ding! Ding! We have a winner! Thanks a lot.
EBGreen
Nice, I was waiting to hear if the row was in the DB to mention this.
northpole
I've been burned by this more times then I can count. The worst is starting a batch job, forgetting to commit the transaction in SQL-Developer (or Toad in this example), and coming back in an hour to see that no progress has been made.
Mark Roddy
Classic case of me knowing just enough about something to get myself into trouble.
EBGreen