title: Return an sql variable's value from within an Oracle Sql Query back to .NET code
body: <p>For the past few hours I am trying to do the simplest of the simple things (at least for SQL SERVER) in an Oracle Data Base, through a .NET application using ADO.NET. It seems impossible.</p>
  
  <p>For SQL SERVER I would do this simple task, supposing I have an SqlCommand object</p>
  
  <pre><code>comm.CommandText = @"
     DECLARE @next_id INT
     SET @next_id = (SELECT ISNULL(MAX(id_col),0) FROM TABLE_1) + 1
     INSERT INTO TABLE_1 (id_col, col1, ...) VALUES (@next_id, val1, ...)
     SELECT @next_id";
  int id = Convert.ToInt32(comm.ExecuteScalar());
  </code></pre>
  
  <p>That would insert a new record to table TABLE_1 and I would take back the new id in the "id" variable in c# code.</p>
  
  <p>Four simple steps</p>
  
  <ul>
  <li>Declare a variable</li>
  <li>Set it to the next available id</li>
  <li>Insert the record with the new variable</li>
  <li>Return the variable's value</li>
  </ul>
  
  <p>Ok I managed to declare the variable in Oracle query. Also I (think) I managed to give it a value (With SELECT INTO)</p>
  
  <p>How can I get back this variable's value back in c#? How can i SELECT a variable's value to the output stream in Oracle SQL?</p>
  
  <p><em>I know that there are better ways to achieve getting back an identity column, but that's not the question here. It could be a totally different example. The question is simple.</em>: I have declared a variable inside an oracle sql script that will be executed from within .net app. <strong>How can i get the variable's value back to c#, from an oracle query?</strong> What is the above code's equivalent with Oracle ADO.NET query?</p>