Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trigger

 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a trigger not sure where I am going wrong. It is showing as Invalid trigger.

 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michell,

what exactly do you want this trigger to do?


John
 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first trigger. I am selecting some of the newly inserted values.using a trigger.
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I see...

Wel, it looks as if you need some guidance on triggers.

Maybe you can start following one of these links:

Tutorial Oracle Triggers

When to use triggers


And one more thing: inside of a trigger you should avoid selects on the table of the trigger. See this:

Avoiding Mutating Tables


John
 
michell o'brien
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Can anyone tell me what mistake I have done in Line 10. It gives me error code number PLSQL-00103
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi michell,

I think when you work with cursors you have to open them, e.g.



Additionally I'm not sure if you're allowed to access table itemtype in your trigger,but since it is an AFTER trigger it may be allowed...

But I think you should read about the :new and : old parameters available in triggers.

If you just want to add an item everytime a new itemtype was added you could write:



So for each row which was inserted into itemtypes an entry into item is made.
If you create this trigger before the firstentry into itemtype was made it will have the same effect as your trigger - of course without "cleaning up" items whose itemtype has been deleted. For this you would need an additional ON DELETE trigger..


John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic