sql - What is the correct way to get created row Id on Oracle using the RETURNING INTO clause in c# and OCI: -
I have the following statement for entering a line and inserting the id or line:
Int ReturnId; Include string sql = "table_name (a, b, c) values (1, 2, 3) return back ID: return iid;"; Oracle Commands Command = conn.CreateCommand (); Command.CommandText = sql; Console.light line ("line created has an id" + return iid);
This does not work. I also tried to make the following differences:
string sql = "table_name (a, b, c) values (1 , 2, 3) Include in Returning ID; "; Oracle Commands Command = conn.CreateCommand (); Command.CommandText = sql; Int rowsUpdated = command.ExecuteNonQuery (); If (rows updated! = 1) return; OracleDataReader Reader = command.ExecuteReader (); While (reader.Read ()) {string id = (string) reader ["ID"]; Console.light line ("line created has an id" + return iid); }
This includes two rows in this database, and the reader is empty.
Your return section is ok
But your C # code is all wrong You must use the Parameters property - Read here:
Example:
< Pre> command.Pameters.ed ("ReturnId", oracleipipe.number). Direction = Parameter Direction.optput;
After executing your query, command. Parameter ["return id"]. Value
Comments
Post a Comment