Using Oracle 9i.
Here's my situation. We have a table TOOL,
When the users insert new records, I want to concatenate the TOOL_TYPE, POWER and TOOL_INVENTORY_ID to create the TOOL_ID.
At first, I was receiving the ORA-04091 error; mutating table error...but I thought this was because I was attempting to update that TOOL table inside a trigger that was triggered by the insert on that TOOL table.
Now, I created 2 triggers.
The first one, enters the data in a log table, with my concatenated record, TOOL_ID and the second trigger that updates the data into my TOOL table. But I receive the error message still.
here are my triggers:
the second one:
any ideas on how to accomplish this?
Here's my situation. We have a table TOOL,
Code:
TOOL_TYPE VARCHAR2 (10) NOT NULL,
POWER NUMBER (4,2) NOT NULL,
TOOL_INVENTORY_ID VARCHAR2 (20) NOT NULL,
TOOL_ID VARCHAR2 (50),
DESIGN_ID VARCHAR2 (30),
ACTIVE
When the users insert new records, I want to concatenate the TOOL_TYPE, POWER and TOOL_INVENTORY_ID to create the TOOL_ID.
At first, I was receiving the ORA-04091 error; mutating table error...but I thought this was because I was attempting to update that TOOL table inside a trigger that was triggered by the insert on that TOOL table.
Now, I created 2 triggers.
The first one, enters the data in a log table, with my concatenated record, TOOL_ID and the second trigger that updates the data into my TOOL table. But I receive the error message still.
here are my triggers:
Code:
CREATE OR REPLACE TRIGGER TR_CREATE_TOOL_ID
AFTER INSERT
ON TOOL
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
vToolType varchar2(100);
BEGIN
vToolType := :new.TOOL_TYPE || '-' || :new.DIOPTER || '-' || :new.TOOL_INVENTORY_ID;
insert into TOOL_LOG values
(:new.tool_type, :new.diopter, :new.tool_inventory_id, vToolType, :new.design_id, :new.active);
END ;
the second one:
Code:
CREATE OR REPLACE TRIGGER CAMS.TR_CREATE_IOL_TOOL_ID_2
AFTER INSERT
ON CAMS.IOL_TOOL_LOG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
BEGIN
update tool
set tool_id = :new.tool_id
where tool_inventory_id = :new.tool_inventory_id
and design_id = :new.design_id
and active = :new.active
and diopter = :new.diopter;
and tool_type = :new.tool_type
END ;
any ideas on how to accomplish this?