• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Table mutating error in Oracle

 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vladan.
 
reply
    Bookmark Topic Watch Topic
  • New Topic