我有一个从并发事务中调用的过程:
//Some actions here
INSERT INTO table1
(table1_id, table1_val1, table1_val2, table1_val3)
VALUES
(gettablenewid('TABLE1'), val1, val2, val3);
INSERT INTO table1
(table1_id, table1_val1, table1_val2, table1_val3)
VALUES
(gettablenewid('TABLE1'), val1, val2, val3);
INSERT INTO table1
(table1_id, table1_val1, table1_val2, table1_val3)
VALUES
(gettablenewid('TABLE1'), val1, val2, val3);
//some other actions函数gettablenewid代码(id_table为每个表存储PKs ):
create or replace
function GetTableNewId(tablename in varchar2)
return number is
PRAGMA AUTONOMOUS_TRANSACTION;
Result number;
cursor c1 is SELECT ig.id_value+1 id_new
FROM id_table ig
WHERE ig.table_identifier = tablename
FOR UPDATE of ig.id_value;
begin
for c1_rec in c1 loop
UPDATE id_table ig
SET ig.id_value = c1_rec.id_new
WHERE current of c1 ;
Result:=c1_rec.id_new;
end loop;
commit;
return(Result);
end GetTableNewId;对于table1_id,偶尔插入语句在ORA-00001中失败,我无法解释为什么会发生这种情况。
发布于 2013-03-14 06:04:45
@A.B.Cade你说得对!我发现了另一个为table_identifier =‘TABLE1 1’并发修改table_identifier的进程。感谢你的帮助。
https://dba.stackexchange.com/questions/36544
复制相似问题