-1
CREATE TRIGGER request_internal_trigger

AFTER INSERT

   ON request_internal_analysis FOR EACH ROW

BEGIN

   INSERT INTO user_action (User_Name , Request_number , Actions , DateOfAlter , state_of_patient)

   VALUES

   ( 'abdo', 
     NEW.Internal_Request_number,
     'Insert',
     NOW(),
     'Internal' )
end

The error message:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'end' at line 12

closed as off-topic by Mark Storey-Smith, Paul White says GoFundMonica, Michael - sqlbot, RLF, Max Vernon Nov 10 '14 at 22:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Mark Storey-Smith, Paul White says GoFundMonica, Michael - sqlbot, RLF, Max Vernon
If this question can be reworded to fit the rules in the help center, please edit the question.

1

With single statement, don't use BEGIN ... END. Use the BEGIN ... END compound statement construct only when to execute multiple statements.

CREATE TRIGGER request_internal_trigger

AFTER INSERT

   ON request_internal_analysis FOR EACH ROW



   INSERT INTO user_action (User_Name , Request_number , Actions , DateOfAlter , state_of_patient)

   VALUES

   ( 'abdo', 
     NEW.Internal_Request_number,
     'Insert',
     NOW(),
     'Internal' )
1

You should add a semi-column after the insert statement, AND should change the delimiter before creating the query:

DELIMITER $$
CREATE TRIGGER request_internal_trigger AFTER INSERT ON request_internal_analysis FOR EACH ROW
BEGIN
    INSERT INTO user_action (User_Name , Request_number , Actions , DateOfAlter , state_of_patient)
    VALUES   ( 'abdo', NEW.Internal_Request_number,'Insert', NOW(),'Internal' );
end$$
DELIMITER ;

Not the answer you're looking for? Browse other questions tagged or ask your own question.