MySQL Forums
Forum List  »  Newbie

Triggers - compare with null
Posted by: SREEVISWA PEESAPATI
Date: September 10, 2008 10:51AM

Hi

I am new to mySQL. I am an Oracle Developer, learning mySQL. Thank you for looking at this post.

1. What is the best tool for mySql front end.

2. Is MySQL code (such as triggers code or names of the columns) are case sensitive when porting from Windows to Linux?

3. Is it possible to write one single trigger on multiple events as in Oracle.
For example in Oracle
CREATE OR REPLACE TRIGGER XYZ BEFORE INSERT OR UPDATE OR DELETE ON EMP FOR EACH ROW
BEGIN
IF INSERTING THEN
....
ELSIF UPDATING THEN
....
ELSE
....
END IF;
END;
/

4. I am trying to create is a trigger on a table in mySQL.
The if statement is not working, when I do a compare with null.
It is executing "ELSE" part, even when I try inserting a null value (I am using Toad for MySQL).

CREATE TRIGGER `cms`.`bir_address_type` BEFORE INSERT ON cms.address_type FOR EACH ROW
BEGIN
if new.effctv_dttm is null then
set new.effctv_dttm = CURRENT_TIMESTAMP;
else
set new.effctv_dttm = '2008-08-08 13:00:00';
end if;
set new.insrtd_by = current_user;
set new.insrtd_dttm = current_timestamp;
END;



Edited 1 time(s). Last edit at 09/11/2008 08:01AM by SREEVISWA PEESAPATI.

Options: ReplyQuote


Subject
Written By
Posted
Triggers - compare with null
September 10, 2008 10:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.