3 added 36 characters in body
source | link

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

CREATE TRIGGER TRG_CREATE_INT_SRV_ROW AFTER INSERT ON survey_details FOR EACH ROW BEGIN IF(New.LossTo == 'Vehicle') THEN INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo); ELSE INSERT INTO survey_other (RefNo) VALUES (New.RefNo); END IF; END;

CREATE TRIGGER TRG_CREATE_INT_SRV_ROW
AFTER INSERT ON survey_details
FOR EACH ROW
BEGIN
 IF(New.LossTo == 'Vehicle') THEN
    INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo);
 ELSE
    INSERT INTO survey_other (RefNo) VALUES (New.RefNo);
 END IF;
END;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

CREATE TRIGGER TRG_CREATE_INT_SRV_ROW AFTER INSERT ON survey_details FOR EACH ROW BEGIN IF(New.LossTo == 'Vehicle') THEN INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo); ELSE INSERT INTO survey_other (RefNo) VALUES (New.RefNo); END IF; END;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

CREATE TRIGGER TRG_CREATE_INT_SRV_ROW
AFTER INSERT ON survey_details
FOR EACH ROW
BEGIN
 IF(New.LossTo == 'Vehicle') THEN
    INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo);
 ELSE
    INSERT INTO survey_other (RefNo) VALUES (New.RefNo);
 END IF;
END;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?

2 Improved question
source | link

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

DELIMITER $$ CREATE TRIGGER TRG_CREATE_INT_SRV_ROW AFTER INSERT ON survey_details FOR EACH ROW BEGIN IF(New.LossTo == 'Vehicle') THEN INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo); ELSE INSERT INTO survey_other (RefNo) VALUES (New.RefNo); END IF; END $$ DELIMITER;END;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

DELIMITER $$ CREATE TRIGGER TRG_CREATE_INT_SRV_ROW AFTER INSERT ON survey_details FOR EACH ROW BEGIN IF(New.LossTo == 'Vehicle') THEN INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo); ELSE INSERT INTO survey_other (RefNo) VALUES (New.RefNo); END IF; END $$ DELIMITER;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

CREATE TRIGGER TRG_CREATE_INT_SRV_ROW AFTER INSERT ON survey_details FOR EACH ROW BEGIN IF(New.LossTo == 'Vehicle') THEN INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo); ELSE INSERT INTO survey_other (RefNo) VALUES (New.RefNo); END IF; END;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?

1
source | link

Need help in creating MySQL trigger

I am writing a trigger in a MySQL to conditionally create a new record in another table based on the value of field in newly added record in a table. Here is the script for the trigger (which should be self explanatory):

DELIMITER $$ CREATE TRIGGER TRG_CREATE_INT_SRV_ROW AFTER INSERT ON survey_details FOR EACH ROW BEGIN IF(New.LossTo == 'Vehicle') THEN INSERT INTO survey_vehicle (RefNo) VALUES (New.RefNo); ELSE INSERT INTO survey_other (RefNo) VALUES (New.RefNo); END IF; END $$ DELIMITER;

While running the query, the error message displayed is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Vehicle') THEN INSERT INTO interim_survey_vehicle (RefNo) VALUES (New.RefNo' at line 5

I am writing this kind of conditional trigger for the first time.

What is wrong with code please?