C#でExecuteOracleNonQueryを使用して、ストアドプロシージャを使用してOracleデータベースにレコードをINSERTするが、ROWIDを返すように見えない。 C#のでC#でExecuteOracleNonQueryからROWIDを取得する方法
... Oracleパッケージ内
using (OracleConnection oc=
new OracleConnection(AppConfiguration.ConnectionString))
{
OracleCommand myCommand = new OracleCommand("PKG_TEST.INSERT", oc);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.AddWithValue("p_Id", allAssets.Id);
myCommand.Parameters.AddWithValue("p_Description", allAssets.Description);
OracleString rowId;
try
{
myConnection.Open();
result = myCommand.ExecuteOracleNonQuery(out rowId);
allAssets.RowId = rowId.ToString();
}
catch(System.Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
finally
{
myConnection.Close();
}
}
return result;
手順...
PROCEDURE insert (
p_id IN ALL_ASSETS.id%TYPE,
p_description IN ALL_ASSETS.description%TYPE
)
IS
BEGIN
INSERT INTO ALL_ASSETS
(id, description)
VALUES (p_id, p_description);
END insert;
は誰もが、ROWIDが返される方法上の任意の光を当てるしてくださいことはできますか?
EDIT - コードを上記のように変更しましたが、まだROWIDが返されません。また、1つのレコードだけが挿入されています。
ありがとうございました。
私はそれが私がそれを最初に宣言しなかった理由だと思ったのです。しかし、私はまだ何も戻っていませんでした。 –
SPが正確に1行に影響していることは絶対に確かですか?ドキュメンテーションは、それが返されないかもしれないことを示唆しています... – Calanus
ええ、私はそれをトレースして、1つのレコードだけが挿入されています。 –