ora-04091

ORA-04091: table [blah] is mutating, trigger/function may not see it

半腔热情 提交于 2019-12-25 04:28:14
问题 I recently started working on a large complex application, and I've just been assigned a bug due to this error: ORA-04091: table SCMA.TBL1 is mutating, trigger/function may not see it ORA-06512: at "SCMA.TRG_T1_TBL1_COL1", line 4 ORA-04088: error during execution of trigger 'SCMA.TRG_T1_TBL1_COL1' The trigger in question looks like create or replace TRIGGER TRG_T1_TBL1_COL1 BEFORE INSERT OR UPDATE OF t1_appnt_evnt_id ON TBL1 FOR EACH ROW WHEN (NEW.t1_prnt_t1_pk is not null) DECLARE v_reassign

ORA-04091 - How can I alter a table that a trigger fires on?

丶灬走出姿态 提交于 2019-12-24 16:27:39
问题 So I have table foo and I would like to delete other foo rows when trigger t_foo fires: CREATE OR REPLACE TRIGGER "t_foo" AFTER INSERT OR DELETE OR UPDATE ON foo /*delete some other records from foo that are not :NEW.* or :OLD.* \* How would I go about doing this without getting a ORA-04091: table name is mutating, trigger/function may not see it. Is this even possible? 回答1: Why not do this in a stored procedure, where you can wrap the insert and deletes in a transaction, and can clearly

problem with trigger in oracle

落花浮王杯 提交于 2019-12-24 11:42:11
问题 the problem is this : I implemented a trigger on the table called CLAN_AFFILIATI that increases (if inseriemento) and decreases (in case of cancellation) an attribute (NUMAFFILIATI) of another table called CLAN. what I would do is block the update NUMAFFILIATI of Clan by the user and had thought to r another trigge on CLAN that did this: trigger on CLAN_AFFILIATI(CLAN VARCHAR,AFFILIATO VARCHAR,RUOLO VARCHAR) CREATE OR REPLACE TRIGGER "AggiornamentoNumAffiliati" AFTER INSERT OR DELETE ON CLAN

Automatically Update Field in Database

孤街醉人 提交于 2019-12-22 00:24:22
问题 I'd like to automatically update a database column with an aggregate of another column. There are three tables involved: T_RIDER RIDER_ID TMP_PONYLIST ... T_RIDER_PONY RIDER_ID PONY_ID T_PONY PONY_ID PONY_NAME ... T_RIDER and T_PONY have an n:m relationship via T_RIDER_PONY . T_RIDER and T_PONY have some more columns but only TMP_PONYLIST and PONY_NAME are relevant here. TMP_PONYLIST is a semicolon spararated list of PONY_NAMES , imagine something like "Twisty Tail;Candy Cane;Lucky Leaf" . I

Delete rows matching substring with LIKE?

我是研究僧i 提交于 2019-12-13 16:34:57
问题 How do you delete rows from a table, where a column contains a substring, but the type of that column is 'Long'. (Yes, I know I shouldn't use Long, but I'm maintaining someone else's mess). My first attempt was: delete from longtable where search_long(rowid) like '%hello%'; (Following on from this answer.) This returns: SQL Error: ORA-04091: table blah.longtable is mutating, trigger/function may not see it 回答1: I just replicated your problem and got the same error - it seems the function can

Oracle After Delete Trigger… How to avoid Mutating Table (ORA-04091)?

北城余情 提交于 2019-12-11 13:46:40
问题 Let's say we have the following table structures: documents docmentStatusHistory status +---------+ +--------------------+ +----------+ | docId | | docStatusHistoryId | | statusId | +---------+ +--------------------+ +----------+ | ... | | docId | | ... | +---------+ | statusId | +----------+ | ... | +--------------------+ It may be obvious, but it's worth mentioning, that the current status of a document is the last Status History entered. The system was slowly but surely degrading in

Automatically Update Field in Database

痞子三分冷 提交于 2019-12-04 19:46:15
I'd like to automatically update a database column with an aggregate of another column. There are three tables involved: T_RIDER RIDER_ID TMP_PONYLIST ... T_RIDER_PONY RIDER_ID PONY_ID T_PONY PONY_ID PONY_NAME ... T_RIDER and T_PONY have an n:m relationship via T_RIDER_PONY . T_RIDER and T_PONY have some more columns but only TMP_PONYLIST and PONY_NAME are relevant here. TMP_PONYLIST is a semicolon spararated list of PONY_NAMES , imagine something like "Twisty Tail;Candy Cane;Lucky Leaf" . I'd like to keep this field up to date no matter what happens to T_RIDER_PONY or T_PONY . My first idea

ora-04091 table is Mutating-

谁都会走 提交于 2019-12-02 23:37:23
问题 I'm using a function which compares all the columns in Table 1 and Table 2 and returns 'Y' or 'N'. Based on that, I will update my Table 1. But when I run the merge statement it displays an error: ora-04091 - Table1 is mutating, trigger/function may not see it How can I fix this? CREATE OR REPLACE function DataChange (in_epmname varchar2) return char is v_epmname table2.empname%type; v_DATA_COUNT varchar2(2); v_DATA_CHANGED char; begin SELECT COUNT (*) into v_DATA_COUNT FROM ( SELECT trim

ora-04091 table is Mutating-

十年热恋 提交于 2019-12-02 08:59:03
I'm using a function which compares all the columns in Table 1 and Table 2 and returns 'Y' or 'N'. Based on that, I will update my Table 1. But when I run the merge statement it displays an error: ora-04091 - Table1 is mutating, trigger/function may not see it How can I fix this? CREATE OR REPLACE function DataChange (in_epmname varchar2) return char is v_epmname table2.empname%type; v_DATA_COUNT varchar2(2); v_DATA_CHANGED char; begin SELECT COUNT (*) into v_DATA_COUNT FROM ( SELECT trim(column1||column2||column3) FROM table1 WHERE empname = in_epmname UNION SELECT trim(column1||column2|

mutating, trigger/function may not see it- error during execution of trigger

不想你离开。 提交于 2019-12-01 00:03:47
CREATE OR REPLACE TRIGGER UPDATE_TEST_280510 AFTER insert on TEST_TRNCOMPVISIT declare V_TRNCOMPNO NUMBER(10); CURSOR C1 IS SELECT B.COMPNO FROM TEST_TRNCOMPVISIT A, TEST_TRNCOMPMST B, TEST_MEMMAST C WHERE A.COMPNO=B.COMPNO AND B.TRNMEMID=C.MEMID AND C.MEMOS>=1000; begin open c1; fetch c1 into V_TRNCOMPNO; UPDATE TEST_TRNCOMPMST SET COMPSTATUS='P', remark='comp is pending due to O/S>1000' WHERE COMPNO=V_TRNCOMPNO AND COMPSTATUS='C'; CLOSE C1; end; I have made this trigger and while insert the row in table- TEST_TRNCOMPVISIT it gives following error- The following error has occurred: ORA-04091: