Home » SQL & PL/SQL » SQL & PL/SQL » dependent column
dependent column [message #213930] Fri, 12 January 2007 16:44 Go to next message
Swoop_Alex
Messages: 1
Registered: January 2007
Junior Member
i have a table with some columns representing grades and an average column. how can i make so when i modify a grade the average is automaticaly updated. thanks
Re: dependent column [message #213931 is a reply to message #213930] Fri, 12 January 2007 16:47 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
Don't store the average; compute it correctly when needed.

[Updated on: Fri, 12 January 2007 16:47] by Moderator

Report message to a moderator

Re: dependent column [message #213939 is a reply to message #213931] Fri, 12 January 2007 21:15 Go to previous messageGo to next message
ab_trivedi
Messages: 460
Registered: August 2006
Location: Pune, India
Senior Member
hi anacedent,

can I use the trigger to solve the problem . i think the mutating table errors will come.

Ashu
Re: dependent column [message #213940 is a reply to message #213930] Fri, 12 January 2007 21:19 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
>can I use the trigger to solve the problem .
No
>i think the mutating table errors will come.
That is correct; which is why it is a BAD idea to store computed/derived values in a table.
Re: dependent column [message #213945 is a reply to message #213940] Fri, 12 January 2007 22:24 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
I take it this is a school exercise. If so, the exercise is to find out how to bypass the mutating table problem. If you use Google or the search facility on this site, you will soon find out how to do it.

Ross Leishman
Re: dependent column [message #214129 is a reply to message #213945] Mon, 15 January 2007 01:47 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You could create a view on the table that included the computed average as a column.
Or you could create an On Commit Fast Refresh Materialized view on the whole table and include the computed column in that.

As the Op was @Swoop_Alex, and the push for a trigger based solution came from @Ab_Trivedi, can we assume they're in the same class?
Previous Topic: replace function wont work with single quotes
Next Topic: suggest a username
Goto Forum:
  


Current Time: Sat Dec 03 22:02:04 CST 2016

Total time taken to generate the page: 0.08661 seconds