Logic in triggers

66 views
Skip to first unread message

johanlar...@gmail.com

unread,
Feb 20, 2014, 11:57:12 AM2/20/14
to tda357...@googlegroups.com
Hi!

I'm not quite getting the hang of how to implement the triggers in Task 4. We're supposed to write the triggers "on the view Registrations instead of on the tables themselves" and I guess we should then in the triggers make sure that students trying to register/unregister causes the proper chain of events. However when trying to execute my trigger creation in iSQL plus i get "Warning: Trigger created with compilation errors". Using SHOW ERRORS TRIGGER Register i get many different messages and some complaining of me using subqueries and the like in the trigger.

So my question is - what logic is allowed in the triggers and where in the triggers should it be placed (I assumed in the action clause BEGIN /*here*/ END)?

Thanks / Johan

Jonas Almström Duregård

unread,
Feb 21, 2014, 2:20:02 AM2/21/14
to johanlar...@gmail.com, tda357...@googlegroups.com
Indeed, you should implement your logic in the body of the trigger. What you can do is to use SELECT ... INTO to store the result of queries in local variables (that you first declare in the header of the trigger). Then use IF-THEN-ELSE to get the program flow you need. In the conditions of the IFs, you can refer to local variables but not execute queries.

If you get lots of errors, try removing most of the body of your trigger and see if it compiles, then introduce a line or two at a  time and make sure it compiles with each addition.

Regards,
Jonas


--
You received this message because you are subscribed to the Google Groups "tda357-vt2014" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tda357-vt201...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages