我的代码:
oracleCom.CommandText = @"declare P_ID tbl_objects.i_id%TYPE;
BEGIN
UPDATE tbl_objects
SET i_status_id = 234
WHERE s_code = '" + objectsChanged[j] +
@"' RETURNING i_id INTO P_ID;
:param_id := P_ID;
END;";
oracleCom.Parameters.Add("param_id", OracleType.Number).Direction = ParameterDirection.Output;
try
{
oracleCom.ExecuteNonQuery();
}
catch
{----------}
编译器生成错误:变量的名称/编号错误。但是当我在 pl/sql developer 中使用这个 sql 时,一切正常。
此代码正常工作:
OracleCommand oracleCom = new OracleCommand
{
Connection = oraConnect,
CommandText = @"declare P_ID tbl_objects.i_id%TYPE;
BEGIN insert into tbl_objects
(s_code, i_status_id)
values
(:s_code, 234)
RETURNING I_ID INTO :p_id;
END;"
};