I wanna make tringger, so after inserting data, the datas ordered by date (here name 'tanggal')
but got error #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 'ORDER BY tanggal ASC;
END' at line 5
DELIMITER $$
CREATE TRIGGER sort_by_tanggal
AFTER INSERT ON laporan_bukubesar
FOR EACH ROW
BEGIN
ALTER TABLE laporan_bukubesar ORDER BY tanggal ASC;
END $$
DELIMITER ;
Related
I am trying to create a mysql trigger on delete to write a record on a history table but everytime I am getting error:
#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 '' at line 14
DELIMITER $$
USE `cedecapr_test`$$
CREATE
DEFINER=`root`#`localhost`
TRIGGER `mytable`.`users_delete`
BEFORE DELETE ON `mytable`.`users`
FOR EACH ROW
BEGIN
INSERT INTO `history_table_users`
VALUES
(
OLD.`username`
);
END$$
Any help will be appreciated. Thanks.
I try to create trigger in MySql but get the following error:
#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 'DELIMITER' at line 1
DELIMITER $$
CREATE TRIGGER library_update
AFTER UPDATE ON wq6vt_vehiclemanager_vehicles
FOR EACH ROW
BEGIN
INSERT IGNORE INTO wq6vt_vehiclemanager_library (maker, model) VALUES(NEW.maker, NEW.vmodel);
INSERT INTO wq6vt_vehiclemanager_library_data (co2_class)
SELECT co2_class FROM wq6vt_vehiclemanager_vehicles
WHERE maker = NEW.maker AND vmodel = NEW.vmodel;
END $$
DELIMITER;
The first query in the trigger do not lead to errors, but second one does. There is some problem with SELECT inside of INSERT ...I think so
there should be a space between the keyword and the symbol,
DELIMITER ;
-- ^ space in between here
I have 2 tables in MySql dealers and dealers_info. I try to create trigger which after deleting info from dealers will delete corresponding rows from dealers info
CREATE TRIGGER del_info AFTER DELETE ON dealers
FOR EACH ROW
BEGIN
DELETE FROM dealers_info WHERE dealer_id = OLD.dealer_id;
END;
But I've got an error:
#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 '' at line 4
change the delimiter to execute the query properly,
DELIMITER $$
CREATE TRIGGER del_info
AFTER DELETE ON dealers
FOR EACH ROW
BEGIN
DELETE FROM dealers_info WHERE dealer_id = OLD.dealer_id;
END $$
DELIMITER ;
Someone tell where there is a bug?
CREATE PROCEDURE catalog_get_departments_list()
BEGIN
SELECT department_id, name FROM department ORDER BY department_id;
END$$
And this error crashes:
#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 '' at line 3
I think you should remove dollars at the end:
CREATE PROCEDURE catalog_get_departments_list()
BEGIN
SELECT department_id, name FROM department ORDER BY department_id;
END
or set delimiter
DELIMITER $$
CREATE PROCEDURE catalog_get_departments_list()
BEGIN
SELECT department_id, name FROM department ORDER BY department_id;
END$$
One more variant for your MySQL client -
CREATE PROCEDURE catalog_get_departments_list()
SELECT department_id, name FROM department ORDER BY department_id;
I tried writing this small trigger in MySQL,
CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff`
FOR EACH ROW BEGIN
INSERT INTO `bckoff` SET `step`=1;
END;
after which I get this error.. I'm a newbie to MySQL.. so please help me out here..
#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 '' at line 3
Even after you fix this error - you'll get another one: you cannot modify the table that your trigger was created at.
Btw, this is how you should create this trigger:
delimiter |
CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff`
FOR EACH ROW BEGIN
INSERT INTO `bckoff` SET `step`=1;
END;
|
delimiter ;