This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Table mutating error in Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Table mutating error in Oracle" Watch "Table mutating error in Oracle" New topic
Author

Table mutating error in Oracle

Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Good Morning world,

Ok, I have to write an Oracle trigger in which I need to do a Select on the table a new record is being added to. I need to get the max value of a column and compare it with the value for that column for the new record.

But running it gives a table mutating error, which makes sense because you are trying to get a value from the table that is being modified at that point. Of course I could move the logic out to the Java class, but in what other way can it be done in the database?


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Vladan Radovanovic
Ranch Hand

Joined: Mar 20, 2000
Posts: 216
Use package variable. Docs also say you can use a PL/SQL-Table or a temporary table but I think first one is the easiest. Search the web. There should be some simle examples out there.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Thanks Vladan.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Table mutating error in Oracle
 
Similar Threads
Error on trigger
java.sql.Timestamp to Oracle date
Oracle Null Value
Please help...triggers issue
Please help..triggers issue