Problem solve Get help with specific problems with your technologies, process and projects.

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)
c2  v2

//function: CreateNewRollId
create or replace function CreateNewRollId
roll_max_id NUMBER(38);
roll_id NUMBER(38);
	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);

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 last published in February 2002

Dig Deeper on Oracle error messages

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.