4

this is the query that i am using

create trigger trig1 after insert on participant for each row
begin
insert into team(sap) select sap from participant order by ID desc limit 1,1
end;

it is supposed to copy the sap field from the participant table into the sap field of the team table after a new row is inserted into the participant table the engine shows me an unexpected end of input error at the end of "end"

i've tried numerous methods to rework the query but i keep getting the same error what am i doing wrong?

thanks

1
  • 2
    We can't know what you are doing wrong unless you post your code. Please post your relevant code. Commented Jan 12, 2013 at 5:08

1 Answer 1

4

You are using trigger than no need to run a query on same table to get latest sap value, you can directly get that value using new.sap.

Problem in your query, In your query you haven't put semicolon(;) after INSERT..SELECT query and END keyword.

This will work for you:

DELIMITER $$

DROP TRIGGER /*!50032 IF EXISTS */ `trig1`$$

CREATE
    TRIGGER `trig1` AFTER INSERT ON `participant` 
    FOR EACH ROW BEGIN
        INSERT INTO team(sap) 
        VALUES(new.sap);
    END;
$$

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

1 Comment

thanks a lot....that worked....actually i did not know what the new keyword was for

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.