我要同时更新三个相互关联的表, 怎样维护数据的一致性, 我现在用的是
//autocommit = false
if dw_1.update() = 1 and dw_2.update() = 1 and ... then
commit;
else
rollback;
end if
我想知道用sql语句怎样写?
update t_1 set ....;
update t_2 set ....;
update t_3 set ....;
...全文
337打赏收藏
高手捡分, 事务的完整性
我要同时更新三个相互关联的表, 怎样维护数据的一致性, 我现在用的是 //autocommit = false if dw_1.update() = 1 and dw_2.update() = 1 and ... then commit; else rollback; end if 我想知道用sql语句怎样写? update t_1 set ....; update t_2 set ....; update t_3 set ....;
楼上的别忘了rollback;
update t_1 ……
if sqlca.sqlcode = 0 then
update t_2 ……
if sqlca.sqlcode = 0 then
update t_3……
if sqlca.sqlcdoe = 0 then
commit using sqlca;
else
rollback;
return
end if
else
rollback;
return
end if
else
rollback;
return
end if
update t_1 ……
if sqlca.sqlcode = 0 then
update t_2 ……
if sqlca.sqlcode = 0 then
update t_3……
if sqlca.sqlcdoe = 0 then
commit using sqlca;
end if
end if
end if