Q

Timestamping all rows of some tables on insert and update

I want to timestamp all the rows of some tables, whenever they are inserted or updated. Insertion is no problem...

- just set DEFAULT sysdate - but I'm stuck on updates. I thought I could use a trigger, but I get an error ORA-04091, that the table is mutating - basically I can't trigger an update in a row that is being updated. Fair enough, I guess, but how could I get around this?

You are getting an ORA-4091 table mutating because probably your UPDATE statement in the trigger is causing the entire table to mutate. This is a common mistake by novice programmers. Instead, the trigger approach is good; try writing:

  :new.timestamp_column := SYSDATE;
This should enter a SYSDATE every time you update the row.

For More Information


This was last published in July 2002

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

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.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close