|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Read the table data in trigger
Hi,
i have a table called Student Name | Result ------|-------- AAAA |50 AAAA |60 BBBB |80 BBBB |90 an AFTER INSERT trigger is created for Student table. When ever there is a new record, this trigger will total up the result for the student. For example, new record with Name AAAA and result 40 is inserted. so trigger will calculate the total for AAAA and return 150. However the trigger return mutating table error instead (ORA-04091: table Student is mutating, trigger/function may not see it), since the trigger read the Student table itself. So, how to get the result 150? Thanks. |
|
#2
|
|||
|
|||
|
show me the code?
if the trigger is using the table that you are currently working on then u will get that error, you have to use :NEW and :OLD to do it or some other way! but why would you wanna use trigger? do you just want an OUTPUT on the screen or what? i think procedure may be better |
|
#3
|
|||
|
|||
|
Quote:
I use trigger because whenever there is new record inserted, the trigger will calculate the total for the particular student, then pass the total amount to other database. This line cause my trigger fail: CURSOR studentRecord IS SELECT result FROM student WHERE name='AAAA' Thanks. |
|
#4
|
||||
|
||||
|
If you need to
Quote:
Just set up a dblink between the two databases and create a view (or a materialized view with "refresh fast on commit" option if you need a better performance). I dont' think a trigger is appropriate for your need. Hope this helps.
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) Last edited by pabloj : March 28th, 2005 at 02:42 AM. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Read the table data in trigger |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|