Using RETURNING to return ID

Using RETURNING to return ID

Postby 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
kurtbilde
 
Posts: 113
Joined: Wed 16 Mar 2005 16:02
Location: Odense, Denmark

Postby 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
Shalex
Devart Team
 
Posts: 7401
Joined: Thu 14 Aug 2008 12:44

Postby kurtbilde » Tue 04 Oct 2011 14:41

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

-Kurt
kurtbilde
 
Posts: 113
Joined: Wed 16 Mar 2005 16:02
Location: Odense, Denmark


Return to dotConnect for Oracle