小弟有个问题:
比如
update tblA set Age='20' where Name='AA';
update tblA set Age='30' where Name='BB';
update tblA set Age='40' where Name='CC';
这三条语句能否改成,访问数据库一次就完成呢?
...全文
22315打赏收藏
SQL能否在一个提交中更新多条记录??
小弟有个问题: 比如 update tblA set Age='20' where Name='AA'; update tblA set Age='30' where Name='BB'; update tblA set Age='40' where Name='CC'; 这三条语句能否改成,访问数据库一次就完成呢?
其实为了适应开发的要求 最好把它放到一个存储过程中这样可以避免很多问题
如 create or replace procedure updatetblA(v_Age1 in varchar2,v_Age2 in varchar2,v_Age3 in varchar2)
begin
update tblA set Age=v_Age1 where Name='AA';
update tblA set Age=v_Age2 where Name='BB';
update tblA set Age=v_Age3 where Name='CC';
/*如果要求必须都执行的话加上
commit*/
end;