Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 18th, 2004, 08:03 PM
tim snl's Avatar
tim snl tim snl is offline
Code Cruncher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Tasmania, Australia
Posts: 119 tim snl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 21 m 20 sec
Reputation Power: 8
Question Do I need 3 triggers for this?

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!

Reply With Quote
  #2  
Old October 18th, 2004, 10:48 PM
tim snl's Avatar
tim snl tim snl is offline
Code Cruncher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Tasmania, Australia
Posts: 119 tim snl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 21 m 20 sec
Reputation Power: 8
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 ; ^^ 

Reply With Quote
  #3  
Old October 19th, 2004, 05:18 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
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

Reply With Quote
  #4  
Old November 3rd, 2004, 11:03 PM
tim snl's Avatar
tim snl tim snl is offline
Code Cruncher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Tasmania, Australia
Posts: 119 tim snl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 21 m 20 sec
Reputation Power: 8
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 ....

Reply With Quote
  #5  
Old November 4th, 2004, 01:11 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Do I need 3 triggers for this?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT