Home » SQL & PL/SQL » SQL & PL/SQL » Help with TRIGGERS (SQL Developer, 11g, XP)
Help with TRIGGERS [message #356716] Sat, 01 November 2008 06:05 Go to next message
kimstar00
Messages: 4
Registered: November 2008
Junior Member
Hello all,

I have two tables:

Table1 Table2
--------- ----------
ID Date ID Score

When Table1 is INSERTed or UPDATEd i want the trigger to check IF Table1 has 5 of the same IDs from the same month, THEN i want the ID to be inserted into Table 2 and the Score to go up by 1.

eg.
Table1
ID Date
1 dd/01/yyyy
1 dd/01/yyyy
1 dd/01/yyyy
1 dd/01/yyyy
1 dd/01/yyyy

Table2
ID Score
1 1


Could someone help me with this? Thanks!
Re: Help with TRIGGERS [message #356719 is a reply to message #356716] Sat, 01 November 2008 06:54 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Why do you need a trigger ? Cant views help you ?

Cool
Rajuvan.
Re: Help with TRIGGERS [message #356720 is a reply to message #356719] Sat, 01 November 2008 06:55 Go to previous messageGo to next message
kimstar00
Messages: 4
Registered: November 2008
Junior Member
Yeah, views could do the job.

But right now i'm just learning triggers and trying different things out, just kinda stuck with this one Confused
Re: Help with TRIGGERS [message #356728 is a reply to message #356716] Sat, 01 November 2008 09:10 Go to previous messageGo to next message
coleing
Messages: 213
Registered: February 2008
Senior Member
Ok - look up mutating tables, and you will see that this is a bad idea with triggers.
Re: Help with TRIGGERS [message #356730 is a reply to message #356716] Sat, 01 November 2008 10:54 Go to previous message
Michel Cadot
Messages: 64132
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Put what already tried and why it does fulfill your requirement.

Before please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter).
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: metadata about tables
Next Topic: Finding Dates of a Given Month in Single Query...?
Goto Forum:
  


Current Time: Wed Dec 07 22:38:28 CST 2016

Total time taken to generate the page: 0.08748 seconds