Ask the Expert

Resolving an ORA-04091 error

Why does this code cause an ORA-04091 error?

load data
infile *
append into table sql_parent
(
	parent_id "CreateNewRollId",
	parent_char  POSITION(1)  CHAR(4),
	parent_value POSITION(5)  CHAR(6)
)
BEGINDATA
c2  v2
c333v333

//function: CreateNewRollId
//
create or replace function CreateNewRollId
RETURN NUMBER
IS
roll_max_id NUMBER(38);
roll_id NUMBER(38);
BEGIN
	select MAX(parent_id) into roll_id from sql_parent;
	roll_max_id := GREATEST(roll_id, NVL(roll_max_id,0))+1;
	RETURN (roll_max_id);
END;
/


    Requires Free Membership to View

The SQLLOAD command inserts data into the sql_parent table. The SQLLOAD uses a stored function called CreateNewRollId that does a SELECT operation on the same table.

You also have a trigger on the insert event of the table. (It's not written, but check that you have such a trigger; 4091 is a specific error message that involves triggers.)

The SQLLOAD command fires the insert and then the trigger works in conjunction with the stored function. It causes a mutation because when you started the insert row, you cannnot do a DML operaion on the SAME table until the insert row completes. To resolve the situation, disable the insert trigger. Do the SQLLOAD statement, and then do the code inside the trigger definition.

For More Information

  • What do you think about this answer? E-mail the editors at editor@searchDatabase.com with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
  • Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.

This was first published in February 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: