Influence of deferred constraint to Table is mutating proble
Hello,
i have a question regarding the 'Table is mutating,
Trigger/Function may not see it'-problem. I
wondered whether a deferrable constraint can solve the problem,
but as I tested it, it's the same
behaviour as before.
Situation:
assume tables LOC_TO and TORDER and the following constraint:
ALTER TABLE LOC_TO ADD (CONSTRAINT LT_TOID FOREIGN KEY (LT_TOID)
REFERENCES TORDER ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED);
assume a trigger on table TORDER:
create or replace trigger tIU_TORDER_ADD
after insert or update of TO_STATE on TORDER
for each row
declare
begin
insert
into loc_to
( lt_locid,
lt_toid )
values
( 'HRL14042',
:new.to_id )
end tIU_TORDER_ADD;
I thought, that on a deferred constraint at the triggered action
no check to TORDER is done, and
that this fact will prevent the ORACLE_ERROR ORA-04091.
Can anyone tell me, why this doesn't work?
Thanks
Titus Leskien
null
There was a loophole in the mutating table gotcha: single row inserts in a BEFORE EACH ROW trigger were not considered mutating, but were in AFTER EACH ROW triggers. This did not apply to INSERT INTO ... SELECT ... statements, which always mutated, even if they only inserted one row.
This is get-out is no longer included in the documentation, but as you have found still applies in the 9.2 database (and it's unlikely Oracle will have broken it in 10g).
Cheers, APC
Similar Messages
-
Reporting exceptions on deferred constraints
Is it possible to report exceptions on deferred constraints? I am using this mechanism to load tables in an arbitrary order and to prevent FK violations whilst loading.
As a starting point, the script below works as expected (enabling and disabling):
CREATE TABLE EXCEPTIONS
( ROW_ID ROWID
, OWNER VARCHAR2(30)
, TABLE_NAME VARCHAR2(30)
, CONSTRAINT VARCHAR2(30)
CREATE TABLE EMP( ENAME VARCHAR2(10));
ALTER TABLE EMP ADD CONSTRAINT EMP_UK UNIQUE (ENAME) DEFERRABLE;
ALTER TABLE EMP DISABLE CONSTRAINT EMP_UK;
INSERT INTO EMP VALUES ('SMITH');
INSERT INTO EMP VALUES ('SMITH');
ALTER TABLE EMP ENABLE CONSTRAINT EMP_UK EXCEPTIONS INTO EXCEPTIONS;
SELECT * FROM EXCEPTIONS;
However, I don't want to disable constraints, because the application may be performing DML in another session.
So in the script below I'm deferring the constraints instead of disabling them. But how can I report the constraint violations in this scenario?
CREATE TABLE EXCEPTIONS
( ROW_ID ROWID
, OWNER VARCHAR2(30)
, TABLE_NAME VARCHAR2(30)
, CONSTRAINT VARCHAR2(30)
CREATE TABLE EMP( ENAME VARCHAR2(10));
ALTER TABLE EMP ADD CONSTRAINT EMP_UK UNIQUE (ENAME) DEFERRABLE;
ALTER SESSION SET CONSTRAINTS=DEFERRED;
INSERT INTO EMP VALUES ('SMITH');
INSERT INTO EMP VALUES ('SMITH');
-- Which statement goes here to report constraint violations?
SELECT * FROM EXCEPTIONS;
The statement:
SET CONSTRAINTS ALL IMMEDIATE;
will validate deferred constraints and result in a SQL Error: ORA-00001: unique constraint (SCOTT.EMP_UK) violated
But this does not tell me the rows.
The statement:
ALTER TABLE EMP ENABLE CONSTRAINT EMP_UK EXCEPTIONS INTO EXCEPTIONS;
results in the following error, and no rows in the exceptions table:
SQL Error: ORA-02091: transaction rolled back
ORA-00001: unique constraint (SCOTT.EMP_UK) violated
Is there any way to report the violations?
At the end, I'd like to report ALL violating rows to the user.
The best I can come up with is, for each constraint perform:
SET CONSTRAINT EMP_UK IMMEDIATE;
and in the exception handler explicitly query for duplicates in the table:
SELECT ENAME FROM EMP GROUP BY ENAME HAVING COUNT(*) > 1;
I hope there is a better way.I believe this will not be usable in a scenario in which the tables are loaded in the "wrong" order. The database will only be consistent after all tables have been loaded. Using DML error logging will produce false errors. Please correct me if I'm wrong.
-
ORA-04091: table is mutating, trigger/function
I am using oracle 11g R2 - 11.2.0.1
I have following function to fetch the ID from name supplied
create or replace
FUNCTION get_group_id
(p_groupname IN group_list.groupname%TYPE)
RETURN group_list.group_id%TYPE
AS
v_group_id group_list.group_id%TYPE;
BEGIN
SELECT group_list.group_id
INTO v_group_id
FROM group_list
WHERE group_list.groupname = p_groupname;
RETURN v_group_id;
END get_group_id;
and I am doing simple update command to the table, but its giving me ORA-04091 error. Any help is appreciated
update GROUP_LIST set MGR_GROUP_ID = get_group_id('manager1') where group_id = get_group_id('employee51');
Error which I am getting is -
Error report:
SQL Error: ORA-04091: table is mutating, trigger/function may not see it
ORA-06512: at "GET_GROUP_ID", line 7
04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
*Cause: A trigger (or a user defined plsql function that is referenced in
this statement) attempted to look at (or modify) a table that was
in the middle of being modified by the statement which fired it.
*Action: Rewrite the trigger (or function) so it does not read that table.>
and I am doing simple update command to the table, but its giving me ORA-04091 error. Any help is appreciated
update GROUP_LIST set MGR_GROUP_ID = get_group_id('manager1') where group_id = get_group_id('employee51');
Error which I am getting is -
Error report:
SQL Error: ORA-04091: table is mutating, trigger/function may not see it
>
And do you have a trigger on the GROUP_LIST table that calls you function that queries the GROUP_LIST table?
The solution is simple: DON'T DO THAT!
See Trigger Restrictions on Mutating Tables in the SQL Language doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/triggers.htm#g1699708
Trigger Restrictions on Mutating Tables
A mutating table is a table that is being modified by an UPDATE, DELETE, or INSERT statement, or a table that might be updated by the effects of a DELETE CASCADE constraint.
The session that issued the triggering statement cannot query or modify a mutating table. This restriction prevents a trigger from seeing an inconsistent set of data.
This restriction applies to all triggers that use the FOR EACH ROW clause. Views being modified in INSTEAD OF triggers are not considered mutating.
When a trigger encounters a mutating table, a run-time error occurs, the effects of the trigger body and triggering statement are rolled back, and control is returned to the user or application. (You can use compound triggers to avoid the mutating-table error. For more information, see Using Compound Triggers to Avoid Mutating-Table Error.)
Consider the following trigger:
CREATE OR REPLACE TRIGGER Emp_count
. . . -
In the Oracle Lite documentation, there is a section:
==========================================================
3.11.3.2 Defer Constraint Checking Until After All Transactions Are Applied
1. Drop all foreign key constraints and then recreate them as DEFERRABLE constraints.
2. Bind user-defined PL/SQL procedures to publications that contain tables with referential integrity constraints.
3. The PL/SQL procedure should set constraints to DEFERRED in the BeforeApply function and IMMEDIATE in the AfterApply function as in the following example featuring a table named SAMPLE3 and a constraint named address.14_fk:
==========================================================
For step 1, I am assuming this is on the base table that the publication references, since it is the one throwing the FK constraint violations at me.
For step 2 however, are these procedures to be bound to the base tables as well, or somewhere else related to where the publication items are stored?
Thanks,
AllenIn this case, the data model that I have to work with causes this situation
TABLE A has 2 FK constraints to TABLE B
TABLE B has 1 FK constraint to TABLE A
In Oracle Lite, I:
1-create a record in TABLE A where both of the columns with FK constraints are null
2-create a record in TABLE B which refers to the original in TABLE A
3-create a second record in TABLE B which also refers to the record in TABLE A
4-update the record in TABLE A to refer to the 2 records in TABLE B
When these changes reach the mobile server, they are placed in the error queue, because steps 1 and 4 are being combined and performed as one single insert. Since the records from step 2 and 3 don't exist yet, there is an FK violation.
Is there a way to prevent the synchronization process from 'opitimizing' the transaction and combining steps 1 and 4? Everything works fine if I follow steps 1-4, but when 1 and 4 are combined it all falls apart.
Thanks,
Allen -
Hi,
One of our projects is using Kodo to link Java to the Oracle db I works fine with 8.1.7 but we need to connect to a Lite db.
Kodo is running this query which fails because Oracle Lite does not have a DEFERRED column in the ALL_CONSTRAINTS table. I can't find any info on deferred constraints in Lite.
Does Lite handle constraints in the same way?
Is there a workaround ?
Peter
SELECT t2.OWNER AS PKTABLE_SCHEM,
t2.TABLE_NAME AS PKTABLE_NAME,
t2.COLUMN_NAME AS PKCOLUMN_NAME,
t0.OWNER AS FKTABLE_SCHEM,
t0.TABLE_NAME AS FKTABLE_NAME,
t0.COLUMN_NAME AS FKCOLUMN_NAME,
t0.POSITION AS KEY_SEQ,
DECODE (t1.DELETE_RULE,
'NO ACTION', 3,
'RESTRICT', 1,
'CASCADE', 0,
'SET NULL', 2,
'SET DEFAULT', 4) AS DELETE_RULE,
t0.CONSTRAINT_NAME AS FK_NAME,
DECODE (t1.DEFERRED,
'DEFERRED', 5,
'IMMEDIATE', 6) AS DEFERRABILITY
FROM ALL_CONS_COLUMNS t0,
ALL_CONSTRAINTS t1,
ALL_CONS_COLUMNS t2
WHERE t0.OWNER = t1.OWNER
AND t0.CONSTRAINT_NAME = t1.CONSTRAINT_NAME
AND t1.CONSTRAINT_TYPE = 'R'
AND t1.R_OWNER = t2.OWNER
AND t1.R_CONSTRAINT_NAME = t2.CONSTRAINT_NAME
AND t0.POSITION = t2.POSITION;Peter,
Please let us know if you still need help with this post.
Thank you. -
Deferred Constraints - error on inserting
Hi there,
i've got a very courios problem with deferred constraints. My table creates are:
CREATE TABLE mitglied
( svnr NUMBER(10) NOT NULL,
instr VARCHAR(20) NOT NULL,
CONSTRAINT mitglied_pk PRIMARY KEY (svnr));
CREATE TABLE abteilung
( instr VARCHAR(20) NOT NULL,
geleitetVon NUMBER(10) NOT NULL,
stvVon NUMBER(10) NOT NULL,
CONSTRAINT abteilung_pk PRIMARY KEY (instr),
CONSTRAINT abteilung_geleitetVon_fk FOREIGN KEY (geleitetVon)
REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE,
CONSTRAINT abteilung_stvVon_fk FOREIGN KEY (stvVon)
REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE);
ALTER TABLE mitglied
ADD CONSTRAINT mitglied_fk FOREIGN KEY (instr)
REFERENCES abteilung(instr) INITIALLY DEFERRED DEFERRABLE;My Inserts (from sql-file):
INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', '20-JAN-2005', 'Posaune');
<all of the other "mitglied"-inserts>
INSERT INTO abteilung VALUES ('Posaune', '1833040984', '1512101070');
<all of the other "abteilung"-inserts>
COMMIT;The Error msg:
Error starting at line 79 in command:
INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', '20-JAN-2005', 'Posaune')
Error report:
SQL Error: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (U0426435.MITGLIED_FK) violated - parent key not found
(it's the same for all of the other mitglied-inserts), and of course, I get also errors on the abteilung-inserts.
I've already tried to solve this problem by using "SET AUTOCOMMIT OFF" in sqlplus, but that wasn't the point.
What's wrong with my Constraints?Please post a complete example cut-n-paste from SQL*Plus window that shows the exact output step by step (as like below).
It apparently works for me as shown below.
SQL> CREATE TABLE mitglied
2 ( svnr NUMBER(10) NOT NULL,
3 mName VARCHAR(30) NOT NULL,
4 gJahr INTEGER NOT NULL,
5 aDat DATE NOT NULL,
6 instr VARCHAR(20) NOT NULL,
7 CONSTRAINT mitglied_pk PRIMARY KEY (svnr));
Table created.
SQL> CREATE TABLE abteilung
2 ( instr VARCHAR(20) NOT NULL,
3 geleitetVon NUMBER(10) NOT NULL,
4 stvVon NUMBER(10) NOT NULL,
5 CONSTRAINT abteilung_pk PRIMARY KEY (instr),
6 CONSTRAINT abteilung_geleitetVon_fk FOREIGN KEY (geleitetVon)
7 REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE,
8 CONSTRAINT abteilung_stvVon_fk FOREIGN KEY (stvVon)
9 REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE);
Table created.
SQL> ALTER TABLE mitglied
2 ADD CONSTRAINT mitglied_fk FOREIGN KEY (instr)
3 REFERENCES abteilung(instr) INITIALLY DEFERRED DEFERRABLE;
Table altered.
SQL> INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', to_date('20-JAN-2005', 'dd-mon-yyyy'), 'Posaune');
1 row created.
SQL> INSERT INTO abteilung VALUES ('Posaune', '1833040984', '1512101070');
1 row created.
SQL> commit ;
commit
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-02291: integrity constraint (OPS$LAPTOP\KKISHORE.ABTEILUNG_STVVON_FK)
violated - parent key not found
SQL>Message was edited by:
Kamal Kishore -
Create unique constraint on table
Hello experts,
Is it possible to define a unique constraint on table fields that aren't part of the primary key?
Thank you in advance.One way is to create an index on the field and make it unique (SE11->GOTO->Indexes). Then in your programs Inserts, Appends and Updates would fail giving you a non zero SY-SUBRC when a program tries to enter a value that already exists.
Don't forget to include MANDT in the index otherwise you'll end up with uniqueness across all clients -
ORA-04091: table is mutating, trigger/function may no
Hi all,
I'm trying to create a trigger, but I got the following:
ERROR at line 1:
ORA-04092: cannot ROLLBACK in a trigger
ORA-06512: at "PKG_PROJ", line 63
ORA-04091: table TBL_DATA is mutating, trigger/function may not see it
ORA-06512: at "T$D_INS_TDATA", line 4
ORA-04088: error during execution of trigger 'T$D_INS_TDATA'My trigger is:
CREATE OR REPLACE TRIGGER T$D_INS_TDATA
AFTER INSERT ON TBL_DATA
FOR EACH ROW
DECLARE
BEGIN
PKG_PROJ.P$INSERT(:NEW.ID);
COMMIT;
END;
/Where meu procedure is:
PROCEDURE P$INSERT
P_ID IN TBL_DATA.ID%TYPE
AS
BEGIN
INSERT INTO TBL_DETAIL
ID_DETAIL, DT_DETAIL, OBS,
SELECT SEQ_DETAIL.NEXTVAL, SYSDATE, 'INSERT TRIGGER TEST'
FROM TBL_DATA DC
AND DC.ID = P_ID
COMMIT WORK;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE_APPLICATION_ERROR(-20102, 'PKG_PROJ.P$INSERT: ' || SQLERRM);
END P$INSERT;Somebody can help me???
thanx!!!! :-)Tad,
I believe you're performing SELECT on the triggering table in the PL/SQL block. In simple words, you're trying to change the information of a table the TRIGGER is created for and you're trying to read data from the same table.
I suggest that you use PL/SQL pragma autonomous_transaction to resolve this, for as per Oracle documentation "The AUTONOMOUS_TRANSACTION pragma instructs the PL/SQL compiler to mark a routine as autonomous (independent). An autonomous transaction is an independent transaction started by another transaction, the main transaction. Autonomous transactions let you suspend the main transaction, do SQL operations, commit or roll back those operations, then resume the main transaction."
Furthermore, you can also refer to the following discussion by Thomas Kyte for further understanding of mutating tables:
Avoiding Mutating Tables
http://asktom.oracle.com/tkyte/Mutate/
Hope this helps.
Regards,
Naveed. -
ORA-04091: table is mutating, trigger/function may not see
Hello All,
I am not an expert in oracle and I have been facing a problem where I get a message as follows :
ORA-04091: table <table> is mutating, trigger/function may not see it
I have a table tab1 which has ID, name, and some other columns. the rows in this table form a parent-child type relationship based on some columns within that table. I have created another table called relationship table. The relationship table has 2 columns ID and parentID. I keep this table up to date using triggers. For example if a new record is inserted or upadted in tab1 which affects the parent - child relationship, i update the relationship table accordingly using an insert / update trigger and it works fine.
I created another trigger as follows
create or replace trigger MY_DELETE_TRIGGER
after delete on tab1
for each row
BEGIN
update relationships a set a.parentID = null where a.parentID = :OLD.ID;
delete from relationships a where a.id = :OLD.ID;
END MY_DELETE_TRIGGER;
Basically what I am doing is, the record once deleted, if it was parent of anybody else, i am setting the parent as null and the record itself, if it was in the relationships as a child, I am removing that row.
This is when I get the table is mutating error, and I don't know how to fix it.
Can anybody please help me,
Thanks in advanceCould you provide more details?
SQL> select * from tab1;
ID NAME
1 test1
2 test2
SQL> select * from relationships;
ID PARENTID
1 1
2 1
SQL> create or replace trigger MY_DELETE_TRIGGER
2 after delete on tab1
3 for each row
4 BEGIN
5 update relationships a set a.parentID = null where a.parentID = :OLD.ID;
6 delete from relationships a where a.id = :OLD.ID;
7 END MY_DELETE_TRIGGER;
8 /
Trigger created.
SQL> delete from tab1
2 where id = 1;
1 row deleted.
SQL> select * from relationships;
ID PARENTID
2
SQL> rollback;
Rollback complete.
SQL> insert into relationships values(1,1);
1 row created.
SQL> select * from relationships;
ID PARENTID
1 1
2 1
1 1
SQL> delete from tab1
2 where id = 1;
1 row deleted.
SQL> select * from relationships;
ID PARENTID
2
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.3.0 - Production -
ORA-04091: table is mutating in a scenario
Hello everyone
I have a scenario like this:
There are 2 schemas USER1 and USER2. There is a table (say STATUS_TABLE) with similar structure in both the schemas. In a certain scenario USER1 needs to tell USER2 about a flag which needs to updated in USER2.STATUS_TABLE. For this an intermediate table (say INTER_TABLE) has been created. Now USER1 inserts an entry in INTER_TABLE table & there is an on insert trigger on INTER_TABLE which updates that flag in USER2.STATUS_TABLE. After this update is done, the record in INTER_TABLE is of no use and should be deleted. Now the delete statement in the same trigger on INTER_TABLE raises ORA-04091: table is mutating. The same thing has to hapeen in other direction as well (eg USER2 to USER1).
Something like this:
USER1.STATUS_TABLE INTER_TABLE USER2.STATUS_TABLE
1 row inserted
---------------->
trigger on insert------->update a flag here
delete that rec from INTER_TABLE
=> ORA-04091: table is mutatingWhat would be the correct approach to implment this functionality ?
I hope i explained the scenario properly :) . If any more details required, please let me know
Thanks
Amardeep SidhuHi,
in Oracle 11g you can use compund trigger to handle all in one.
Here is a sample for < Oracle 11g
CREATE OR REPLACE PACKAGE var
IS
TYPE id_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
ids id_tab;
END;
CREATE TABLE inter_table (
id NUMBER,
text VARCHAR2(10)
CREATE OR REPLACE TRIGGER bis_inter_table
BEFORE INSERT ON inter_table
BEGIN
var.ids.delete;
END;
CREATE OR REPLACE TRIGGER bir_inter_table
BEFORE INSERT ON inter_table FOR EACH ROW
BEGIN
var.ids(var.ids.count+1) := :NEW.id;
END;
CREATE OR REPLACE TRIGGER asi_inter_table
AFTER INSERT ON inter_table
BEGIN
FORALL n IN INDICES OF var.ids
DELETE inter_table WHERE id = var.ids(n);
FORALL n IN INDICES OF var.ids
UPDATE status_table SET flag = 1 WHERE id = var.ids(n);
END;
CREATE TABLE status_table (
id NUMBER,
text1 VARCHAR2(10),
flag NUMBER
INSERT INTO status_table VALUES(1, 'Text1', 0);
INSERT INTO status_table VALUES(2, 'Text2', 0);
INSERT INTO status_table VALUES(3, 'Text3', 0);
INSERT INTO status_table VALUES(4, 'Text4', 0);
SELECT * FROM status_table;
SELECT * FROM inter_table;
INSERT INTO inter_table VALUES(1, 'Text1');
SELECT * FROM status_table;
SELECT * FROM inter_table;
COMMIT;...have fun :) -
FOREIGN KEY CONSTRAINT 의 MASTER TABLE NAME 의 확인
제품 : ORACLE SERVER
작성날짜 : 1995-11-02
FOREIGN KEY CONSTRAINT 의 MASTER TABLE NAME 의 확인
===================================================
다음은 FOREIGN KEY CONSTRAINT 이름으로 REFERENCE 하는 TABLE
(MASTER TABLE)을 찾는 SQL SCRIPT이다.
col Primary_key_table format a20
col Constraint_name format a20
select a.object_name Primary_Key_table,
c.name Constraint_name
from dba_objects a,
sys.cdef$ b,
sys.con$ c
where c.name = 'EMP_FOREIGN_KEY' -- CONSTRAINT NAME
and b.con# = c.con#
and b.robj# = a.object_id
/The set of constraints as you show it is valid, but will likely result in a lot of violations since both child columns are larger than the parent. The Oracle 2256 error has nothing to do with data validation, nor with the different lengths of the columns. The documentation says
02256, 00000, "number of referencing columns must match referenced columns"
// *Cause: The number of columns in the foreign-key referencing list is not
// equal to the number of columns in the referenced list.
// *Action: Make sure that the referencing columns match the referenced
// columns.Look at the actual statement that the client ran. It will be different than the one you posted. one of the two column lists will have more columns than the other. -
FOREIGN KEY CONSTRAINT의 MASTER TABLE을 REFERENCE하는 TABLE 찾기
제품 : SQL*PLUS
작성날짜 : 2003-12-17
FOREIGN KEY CONSTRAINT의 MASTER TABLE을 REFERENCE하는 TABLE 찾기
================================================================
Master table 이 dept2일 때, 이 테이블을 참조하는 table들을 찾는 SQL
select x.table_name "reference table"
from
(select distinct r_constraint_name,table_name
from all_constraints
where constraint_type='R' ) x, all_constraints a
where a.table_name = 'DEPT2'
and x.r_constraint_name = a.constraint_name; -
Reporting of deferred constraint failures
Hello
I'm running Kodo 3.1.4 in WebLogic 8.1 against Oracle 9. I'd like to run
with deferred constraints but there are problems reporting failures of
these constraints: the database rolls back but no exception is thrown by
weblogic or KoDo. The user is therefore presented with a silent failure
(though the correct exception is written into the weblogic container log).
Running with DataSourceMode set to enlisted (rather than local) produces
the expected exceptions when constraints fail but the constraints are no
longer correctly deferred (they are tested after each statement).
I'm all out of ideas. Can anyone point me in the right direction?
TIA
RobertThere should be some sort of client exception... are you sure that you
are not consuming it? Are you using a WL datasource?
Robert Donkin wrote:
Hello
I'm running Kodo 3.1.4 in WebLogic 8.1 against Oracle 9. I'd like to run
with deferred constraints but there are problems reporting failures of
these constraints: the database rolls back but no exception is thrown by
weblogic or KoDo. The user is therefore presented with a silent failure
(though the correct exception is written into the weblogic container log).
Running with DataSourceMode set to enlisted (rather than local) produces
the expected exceptions when constraints fail but the constraints are no
longer correctly deferred (they are tested after each statement).
I'm all out of ideas. Can anyone point me in the right direction?
TIA
Robert--
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
Deferred constraints & XAExceptions details
When executing an XA transaction on Oracle 8i with a J2EE server, we are not getting enough details in the OracleXAException that occurs as a result of a deferred constraint being violated (during the commit).
We're getting a oracle.jdbc.xa.OracleXAException (wrapped inside a TransactionRolledBackException), and upon further inspection I can call the OracleXAException methods:
getOracleError() : int
getOracleSQLError() : int
I cannot get any textual details about the error (ie. which constraint was violated).
Do other version of Oracle provide more details during XA transaction failures?
Thanks,
M<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by SAMEER DESHPANDE ([email protected]):
Hello
I would like to know the use of Deferred Constraints.
At the time of COMMMIT, the Oracle ROLLBACKS the transaction if I set "SET CONSTRAINT ALL DEFERRED;"...
What is the use of DEFERRED CONSTRAINTS...?
Thanks
Sameer<HR></BLOCKQUOTE>
You can do "SET CONSTRAINT ALL IMMEDIATE" before committing. That statement will raise an error, without rolling back the transaction, if there are violated constraints. -
Table is mutating, trigger/function may not see it
Hi,
I have been trying to get a trigger to execute a stored procedure when an update is made to a row in a table.
The procedure works when ran manually and the trigger compiles but when the trigger is fired I get a "table is mutating, trigger/function may not see it" error.
Here's a bit more background:
I have a product table where the cost of a product is calculate based on costs in other tables (e.g. cost of raw materials is in the suppliesrawmat table).
I have written a procedure (called proc_costcalc) which takes in a productID and updates that product's cost in the product table.
I want a trigger to do this for every affected product when a rawmaterial cost is changed.
The code of my trigger is:
CREATE OR REPLACE trigger trig_rawcostupdate
AFTER INSERT OR UPDATE ON suppliesrawmat FOR EACH ROW
DECLARE
cursor c1 is
SELECT p.prodid
FROM process p,
(SELECT s.processid
FROM stage s,
(SELECT stageno
FROM stagerawmat
WHERE prodid = :new.prodid) subquery0
WHERE s.stageno = subquery0.stageno) subquery1
WHERE p.processid = subquery1.processid;
BEGIN
FOR tuple in c1
LOOP
proc_costcalc(tuple.prodid);
END LOOP;
END;
The query for the cursor generates a list of productIDs which I need to run through the proc_costcalc procedure.
Can anyone show me where I am going wrong? How can I fix this?
Thanks
KeithI'm afraid I'm still not getting this.
Suppose I have 4 tables (product, madefrom, rawmat and suppliesrawmat).
Product (productid, cost)
Madefrom (productid, rawmatid)
Rawmat (rawmatid)
Suppliesrawmat (supplierid, rawmatid, cost)
The cost of a product should be the sum cost of all rawmaterials it is made from where the cheapest supply cost of that material is used.
What I want to do is update the cost of a product when the cost of a raw material used in its production changes.
My earlier attempt was to have a procedure which when given a productid updates the price of that product. However, when trying to call this procedure from an update on the suppliesrawmat table I recieved the table is mutating error. I now understand why (thanks to everyone for that) but I still don't really know how to rectify the problem.
How should I be doing this?
Thanks again
Keith
Maybe you are looking for
-
How to I get rid of Spam?
I get so much spam on my Verizon account I can't use it as my main account. I get pages of spam every day. I have a g-mail account and a mac.com account that works great. Wish verizon.net did. I would think that Verizon would have a spam filter.
-
I have XP and had to crate a new user for myself do to it freezing I deleted the other one already and now I keep getting a message that says the folder is locked or you do not have write permission for this folder I can not open iTunes folder in My
-
XDMCP problems in SOLARIS 10 Rel 06/06
I just reinstalled Solaris 10 rel 06/06 and when I try to connect from my laptop I get to the login screen entered my id and password then the screen turns black and I get drop. I can figure out why is doing that I have previously running the rel 01/
-
Jdev 11g: question about dvt:shapeAttributes and property "alt"
Hi, Jdev 11.1.1.0.2 I use dvt:shapeAttributes> within a declarative component. This code works fine: <dvt:shapeAttributesSet> <dvt:shapeAttributes component="GAUGE_INDICATOR" alt="Your Tooltiptex
-
Hi, I have updated my iPhone 3GS 32GB to iOS5 and iTunes to version 10.5. All music, videos and ringtones purchased were deleted on the device and now it is impossible at all to sync the iPhone with the computer, both by USB and Wi Fi. It always appe