Using RETURNING to return ID

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
kurtbilde
Posts: 114
Joined: Wed 16 Mar 2005 16:02
Location: Odense, Denmark

Using RETURNING to return ID

Post by kurtbilde » Tue 20 Sep 2011 12:04

Hi,

Trying to use RETURNING to get ID.

Code: Select all

myConn.Open();
  OracleCommand myCommand = new OracleCommand(
      "INSERT INTO T (NUM, VAL) VALUES (:NUM, :VAL) RETURNING ROWID INTO :Parameter1", myConn);
  myCommand.ParameterCheck = true;
  myCommand.Prepare();
  myCommand.Parameters[0].Value = 60;
  myCommand.Parameters[1].Value = 10;
  myCommand.Parameters.Add("Parameter1", oracleDbType.RowId).SourceColumn = "ROWID"; 
  myCommand.Parameters["Parameter1"].Direction = ParameterDirection.[b]Output[/b]; 
  myCommand.ExecuteNonQuery();
  int Param1 = myCommand.Parameters["Parameter1"].Value;
  Console.WriteLine(Param1.ToString);
MyCommand.close();


This shouldn't work shoun't it?

-Kurt

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 21 Sep 2011 15:48

This works (Param1 should be of the string type). Could you please describe the problem?
You can trace the parameters collection and the command execution with the dbMonitor tool:
Download link: http://www.devart.com/dbmonitor/dbmon3.exe
Documentation: http://www.devart.com/dotconnect/oracle ... nitor.html

kurtbilde
Posts: 114
Joined: Wed 16 Mar 2005 16:02
Location: Odense, Denmark

Post by kurtbilde » Tue 04 Oct 2011 14:41

Yep! And sorry for the late reply! It is working!!!!

-Kurt

Post Reply