0

I have a trigger like this

 CREATE
 TRIGGER `hrm_to_odm_user` AFTER INSERT
 ON `ohrm_user`
 FOR EACH ROW BEGIN
  DECLARE _dep_id INTEGER;
        SELECT eeo_cat_code INTO _dep_id FROM hs_hr_employee WHERE emp_number = NEW.id;
  INSERT INTO zodm_user (id, username, password, department) VALUES (NEW.id, NEW.user_name, NEW.user_password, _dep_id);
    END

After inserting data to ohrm_user i fire the trigger to insert values to zodm_user

It works fine for everything else other than this field _dep_id which i select from another table named hs_hr_employee

I have gone thru this post

MySQL Trigger Update with select from another table

but it is not working for me

Thanks

Community
  • 1
  • 1
zamil
  • 1,920
  • 4
  • 17
  • 32

1 Answers1

0

Try something like this

_dep_id = ID hs_hr_employee WHERE emp_number = NEW.id;

Also use profiler to see what query its firing up

Nipun Ambastha
  • 2,553
  • 1
  • 16
  • 26