|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Hello everyone,
I have a simple question. I want to post an event after a record in a specific table is inserted, updated or deleted. Will I need to use 3 triggers to post this message? It seems like i should be able to do this with just 1 trigger? Have i missed something or is this just the way it is? Thanks for your help. Tim
__________________
Beware of a programmer with a screwdriver! |
|
#2
|
||||
|
||||
|
Ok, chill out everyone, i found how to do it
Code:
SET TERM ^^ ; CREATE TRIGGER MYTABLE_MSG FOR MYTABLE ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0 AS begin IF(NEW.TYPE = 'I') THEN POST_EVENT 'MY_EVENT'; end; ^^ SET TERM ; ^^ |
|
#3
|
|||
|
|||
|
As a sidenote: this only works with Fb 1.5 and up. It's a new feature named "universal triggers". For Fb 1, you need to create 3 triggers, one for each action (update/insert/delete).
-- With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com
__________________
Martijn Tonies Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle Upscene Productions http://www.upscene.com |
|
#4
|
||||
|
||||
|
If I use this new feature "universal triggers", in the code of the trigger is there any way to tell which of the conditions actually caused the trigger
So i could do ... Code:
if INSERT then ..... else if UPDATE then .... |
|
#5
|
|||
|
|||
|
Yes, there is - read the Release Notes on this feature.
I believe it's like this: IF (INSERTING) THEN ... IF (DELETING) THEN ... IF (UPDATING) THEN ... or like: IF ( INSERTING OR DELETING ) THEN ... With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Do I need 3 triggers for this? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|