List:General Discussion« Previous MessageNext Message »
From:Duane Hill Date:January 7 2006 5:01am
Subject:Re: Condition within a trigger
View as plain text  
Sorry for responding to my own message. I figured this out.

DELIMITER //
CREATE TRIGGER only_this AFTER INSERT ON table_a
FOR EACH ROW
BEGIN
  IF NEW.email_addr LIKE '%@example.com' THEN
    INSERT INTO table_b (email_addr,value) VALUES (NEW.email_addr,0);
  END IF;
END

On Saturday, January 7, 2006 at 2:39:07 AM, d.hill@stripped confabulated:

> Hello All,

>   I've  been  racking  my  brain  trying  to figure out something. I'm
>   relatively  new  to  the arena of SQL and have been doing a bunch of
>   reading and experimenting.

>   I  have  found  a  need for a trigger that will fire after an insert
>   into  a table. The trigger needs to act only if the value of a field
>   contains something.

>   CREATE TRIGGER only_this AFTER INSERT ON table_a
>   FOR EACH ROW
>     INSERT INTO table_b (email_addr,value) values (NEW.email_addr,0);

>   This  trigger  works  fine.  However,  I  only  want it to fire when
>   NEW.email_addr  contains  a  specific  domain name. This is the part
>   that is causing me confusion.

--

"This message is made of 100% recycled electrons."

Thread
Condition within a triggerDuane Hill7 Jan
  • Re: Condition within a triggerDuane Hill7 Jan