-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

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' )
| improve this answer | |
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 ;
| improve this answer | |

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