Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 1938
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T08:12:19+00:00 2022-05-31T08:12:19+00:00

database – check and suggest the correction in the mysql trigger

  • 0

[ad_1]

i am trying to trigger in my SQL checking a few online info I created this trigger could you suggest me the changes I need to make or the right solution for my situation

create trigger  emp_trigger after insert on emp for each row
 begin
 if emp_pos="trainee" then
 insert into emp (emp_sal) value (5000.00),
 (JSON_OBJECT(
     "dmltype", NEW.dmltype,
     "title", NEW.title,
     "begdate", NEW.begdate,
     "enddate", NEW.enddate,
     "referredby", NEW.referredby,
     "comments", NEW.comments,
     "destination", NEW.destination,
     "modifydate", NEW.modifydate 
    )),
    ('insert',CURRENT_TIMESTAMP);
 end if;
  if emp_pos="python dev" then 
 insert into emp(emp_sal) value (25000.00),
 (JSON_OBJECT(
     "dmltype", NEW.dmltype,
     "title", NEW.title,
     "begdate", NEW.begdate,
     "enddate", NEW.enddate,
     "referredby", NEW.referredby,
     "comments", NEW.comments,
     "destination", NEW.destination,
     "modifydate", NEW.modifydate 
    )),
    ('insert',CURRENT_TIMESTAMP);
 end if;
 if  emp_pos="full stack dev" then
 insert into emp(emp_sal) value (30000.00),
 (JSON_OBJECT( 
     "dmltype", NEW.dmltype,
     "title", NEW.title,
     "begdate", NEW.begdate,
     "enddate", NEW.enddate,
     "referredby", NEW.referredby,
     "comments", NEW.comments,
     "destination", NEW.destination,
     "modifydate", NEW.modifydate 
    )),
    ('insert',CURRENT_TIMESTAMP);
 end if;
 if emp_pos="devops" then 
 insert into emp(emp_sal) value (35000.00),
 (JSON_OBJECT(
     "dmltype", NEW.dmltype,
     "title", NEW.title,
     "begdate", NEW.begdate,
     "enddate", NEW.enddate,
     "referredby", NEW.referredby,
     "comments", NEW.comments,
     "destination", NEW.destination,
     "modifydate", NEW.modifydate 
    )),
    ('insert',CURRENT_TIMESTAMP);    
 end if;
 end    

while I tried to execute the code it presented this error

Error Code: 1054. Unknown column 'dmltype' in 'NEW' 0.015 sec

my situation is I created a emp table while adding the position of the employee in emp_pos column the trigger should fill the sal column
I want to created a log based on the changes if there is other way please do suggest the way.

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 4775 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1063 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1009 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.