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

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.