INSERT Stored procedure not working for mySql - mysql

I'm trying to create DELETE stored procedure for a mysql table. The query runs and shows that the query was successful but when I try to view the stored procedure in 'routines', it doesn't show the DELETE stored procedure. This is my code for creating the stored procedure
DELIMITER //
CREATE PROCEDURE sp_AccessLevel_Delete(IN id INT)
BEGIN
DELETE AccessLevel
WHERE AccessLevelID = id;
END
//
DELIMITER ;
What can I do to fix this?

#siyual: putting this here since it won't fit into a comment:
[test]> delete foo where bar=2;
ERROR 1064 (42000): 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 'where bar=2' at line 1
[test]> delete foo;
ERROR 1064 (42000): 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 '' at line 1
[test]> delete from foo;
Query OK, 1 row affected (0.00 sec)

Related

Error adding update trigger to select columns in a table

I am trying to add a trigger, when a table is updated (except for two columns in that table), it updates another table. The query I used is given below:
CREATE TRIGGER my_trigger
BEFORE UPDATE ON town_1a2b3c4d
BEGIN
IF NOT UPDATE (is_killed) AND NOT UPDATE (is_executed)
BEGIN
UPDATE town_details SET game_index = game_index + 1 WHERE town_id = '1a2b3c4d';
END;
END;
But it gives me this error:
MySQL said
#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 'BEGIN
IF NOT UPDATE (is_killed) AND NOT UPDATE (is_executed)
BEGIN...' at line 3

sql 1064 error when creating a stored procedure

i am attempting to multiple values from 2 tables and display them in a table join. ive been trying to get this to work using a stored procedure. my query works fine as when i tested it removing the argument and inserting a value i got results. i have never used stored procedures before and after reformatting the query and checking spellings and such i cant get it to work.
mysql> DELIMITER $$
mysql>
mysql> DROP PROCEDURE IF EXISTS `parts`.`proc_weight` $$
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE PROCEDURE `parts`.`proc_weight` (IN inputSupplier varchar(45))
->
-> BEGIN
-> SELECT parts.p_nr, project_parts_required.required_qty * parts.weight AS total_weight
-> FROM parts
-> INNER JOIN project_parts_required ON parts.p_nr = project_parts_required.part_nr
-> WHERE project_parts_required.s_nr = inputSupplier
-> END $$
ERROR 1064 (42000): 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 8
mysql>
mysql> DELIMITER ;

Error 1064 trying to create new trigger

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.

MySql on update trigger. Error of DELIMITER

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

Mysql insert command syntax

I am using MYSQL 5.1, I am trying to write an insert statement in my java class. It sounds very simple but i tried and getting exception. I am sure there is a syntax error with my code. below is the snippet could any one help me out here.
ID is in primary key
atm_ID is varchar
trasn_id is varchar
sysDate is Date
rest is int
Please help me out.
Error:
SQL statement is not executed!com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '£10, £20, £50, £100, trans_Id) VALUES (7,'hello','hello','2','2','2','2','2','he' at line 1`
Code:
String query = "INSERT INTO atm_data (ID,atm_Id, sysDate, availBalance, £10, £20, £50, £100, trans_Id) VALUES (7,'hello','2010-09-15 01:20:06','2','2','2','2','2','hello')";
It looks like you simply need to escape the column names that start with £ with backticks:
INSERT INTO atm_data (ID, ... `£10`, `£20`, `£50`, `£100` ...
Test case:
CREATE TABLE tb (`£10` int);
Query OK, 0 rows affected (0.05 sec)
INSERT INTO tb (£10) VALUES (10);
ERROR 1064 (42000): 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 '?10) VALUES (10)' at line 1
INSERT INTO tb (`£10`) VALUES (10);
Query OK, 1 row affected (0.00 sec)