遇到一个问题,实在解决不了,所以贴到论坛上,请教 ~~ 在c# 程序中调用oracle的存储过程,并且调用的存储过程中 有事务处理的代码 (关键是 savepoint X ,roll back )
如果注释掉 savepoint X 这句话,就不会出现异常 ~~ 如下为异常的详细信息 :栈跟踪:
[Exception: ORA-02074: 无法在分布式事务处理中ROLLBACK
ORA-06512: 在"MB_MMS_SCHOOL_777.PK_IMPORT", line 407
ORA-02074: 无法在分布式事务处理中SET SAVEPOINT
ORA-06512: 在line 1
]
SendSms.btnSubmitSMS_Click(Object sender, EventArgs e) in e:\source\GaoXiaoTongMIS\SendSms.aspx.cs:127
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838
如果注释掉 savepoint X 这句话,就不会出现异常 ~~ 如下为异常的详细信息 :栈跟踪:
[Exception: ORA-02074: 无法在分布式事务处理中ROLLBACK
ORA-06512: 在"MB_MMS_SCHOOL_777.PK_IMPORT", line 407
ORA-02074: 无法在分布式事务处理中SET SAVEPOINT
ORA-06512: 在line 1
]
SendSms.btnSubmitSMS_Click(Object sender, EventArgs e) in e:\source\GaoXiaoTongMIS\SendSms.aspx.cs:127
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838
{
con = sh.CreateConn();
command.Connection = con; command.CommandText = "pk_import.pr_mobile_sendsms";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("iId", OracleType.VarChar,100).Value = id;
command.Parameters.Add("iPhone", OracleType.VarChar,100).Value = phones;
command.Parameters.Add("iSms", OracleType.VarChar,100).Value = str_content;
command.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
ORESULT := DEF_FAIL;
SAVEPOINT WSSMSSUBMIT1;
BEGIN
vSubSYSID := ISUBSYSID;
if (vSubSYSID is null) then
vSubSYSID := DEF_SUB_SYS_ID;
end if;……
…… EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO WSSMSSUBMIT1;
insert into a(b) values('132');
SAVEPOINT WSSMSSUBMIT1;
commit;
exception when others then
ROLLBACK TO WSSMSSUBMIT1;
end;
可以自行的
.net 和java 的处理机制 有啥不同? ~~~ tks!~
ORESULT := DEF_FAIL;
BEGIN
SAVEPOINT WSSMSSUBMIT1;
vSubSYSID := ISUBSYSID; 这个换个位置看看,不行就再换了看看
是不能修改的。只能考虑在程序里来处理 。
begin
SAVEPOINT WSSMSSUBMIT1;
insert into a(b) values('132');
commit;
exception when others then
ROLLBACK TO WSSMSSUBMIT1;
end inserta;
OracleConnection con = new OracleConnection("....");
OracleCommand command = new OracleCommand();
command.Connection = con;
try
{
con.Open();
command.CommandText = "inserta";
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();
}
catch (Exception ex)
{
con.Close();
throw new Exception(ex.Message);
}
我调用了一下,没有问题,你先简化一下存储过程,然后一点点调试,看看究竟哪一步错了
Workaround Oracle Bug 914652=true
ODBC: check the option in the DSN configuration entitled "disable MTS
support"
OracleConnection con = new OracleConnection("Data Source=mydatasource;User Id=username;Password=pwd;Workaround Oracle Bug 914652=true
"); 这样写连接字符串,就不会出现异常了。;> o~~这是Oracle的一个Bug 914652 在目前的开发环境中无法解决。