752
社区成员
发帖
与我相关
我的任务
分享
可以这样写,更清晰和捕捉错误些·
string ls_temp_string1,ls_temp_string2
ls_temp_string1="a"
ls_temp_string2="b"
//a数据插入
INSERT INTO T_a(……)
USING at_Trans;
if sqlca.sqlcode <> 0 then
//a数据插入失败
ROLLBACK USING at_Trans;
gf_wtkj_log(ls_temp_string1)
openwithparm(w_message_error,"数据库故障1")
return STATE_ERROR
end if
//b数据插入
INSERT INTO T_b(……)
USING at_Trans;
if sqlca.sqlcode <> 0 then
//b数据插入失败
ROLLBACK USING at_Trans;
gf_wtkj_log(ls_temp_string1+ls_temp_string2)
openwithparm(w_message_error,"数据库故障2")
return STATE_ERROR
end if
//c数据插入
INSERT INTO T_c(……)
USING at_Trans;
//c数据插入失败
if sqlca.sqlcode <> 0 then
ROLLBACK USING at_Trans;
gf_wtkj_log(ls_temp_string1)
openwithparm(w_message_error,"数据库故障3")
return STATE_ERROR
end if
commit using at_Trans;
string ls_temp_string1,ls_temp_string2
ls_temp_string1="a"
ls_temp_string2="b"
//a数据插入
INSERT INTO T_a(……)
USING at_Trans;
if at_Trans.SqlCode = 0 then
//b数据插入
INSERT INTO T_b(……)
USING at_Trans;
if at_Trans.SqlCode = 0 then
//c数据插入
INSERT INTO T_c(……)
USING at_Trans;
COMMIT USING at_Trans;
if at_Trans.SqlCode = 0 then
return STATE_OK
else
//c数据插入失败
ROLLBACK USING at_Trans;
gf_wtkj_log(ls_temp_string1)
openwithparm(w_message_error,"数据库故障3")
return STATE_ERROR
end if
else
//b数据插入失败
ROLLBACK USING at_Trans;
gf_wtkj_log(ls_temp_string1+ls_temp_string2)
openwithparm(w_message_error,"数据库故障2")
return STATE_ERROR
end if
else
//a数据插入失败
gf_wtkj_log(ls_temp_string1)
openwithparm(w_message_error,"数据库故障1")
return STATE_ERROR
end if