Please need help:
DELIMITER $$
CREATE PROCEDURE `getTodayCheckOuts`
BEGIN
SELECT `tec_check_out`.`date`,`tec_check_out_items`.`check_out_id`,`tec_check_out_items`.`item_id`,CONCAT(`tec_items`.`name`,' - ',`tec_items`.`code`) AS 'name',SUM(`tec_check_out_items`.`quantity`) AS 'totla_qty',SUM(`tec_check_out_items`.`quantity`*`tec_check_out_items`.`price`) AS 'total_price'
FROM `tec_check_out_items`, `tec_items`, `tec_check_out`
WHERE `tec_check_out_items`.`item_id`=`tec_items`.`id`
AND `tec_check_out_items`.`check_out_id`=`tec_check_out`.`id`
AND DATE(`tec_check_out`.`date`) = DATE(NOW())
GROUP BY `tec_check_out_items`.`item_id`
END $$
DELIMITER ;
keep getting this error
Error
Static analysis:
2 errors were found during analysis.
Unrecognized data type. (near "." at position 163)
Unrecognized data type. (near "," at position 176)
#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
SELECT `tec_check_out`.`date`,`tec_check_out_items`.`check_out_id`,`tec_' at line 2
Change:
/*
CREATE PROCEDURE `gettodaycheckouts`
*/
by:
CREATE PROCEDURE `gettodaycheckouts`()
and
/*
GROUP BY `tec_check_out_items`.`item_id`
*/
by:
GROUP BY `tec_check_out_items`.`item_id`;
Related
I need the right syntax for MySQL trigger:
CREATE TRIGGER `parent_comm`
BEFORE UPDATE ON `employee` FOR EACH ROW
BEGIN
SET NEW.`parent_com`=(NEW.`com_amt`*10/100)
WHERE `id` = NEW.`parent_id`
END;
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 'WHERE id = NEW.parent_id
END' at line 5
I'm working on a php project and i'm still a novice in error debugging.
whenever i try to execute the following code
CREATE PROCEDURE insertData(Name varchar(255),Description text)
BEGIN
INSERT INTO categories(name,description) VALUES (Name,Description);
END
i get an error stating (in phpmyadmin)
MySQL said: Documentation
#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 '' at line 3
Try using a DELIMITER statement:
DELIMITER $$
CREATE PROCEDURE insertData (
in_Name varchar(255),
in_Description text
)
BEGIN
INSERT INTO categories(name, description)
VALUES (in_Name, in_Description);
END;$$
DELIMITER ;
Notice that I also renamed in the input parameters so they are less likely to be confused with column names. This is a good practice when writing stored procedures and functions.
I have tried to create the following trigger but it is not working:
delimiter //
CREATE TRIGGER DeleteFeature
AFTER DELETE ON Features
FOR EACH ROW BEGIN
IF (OLD.FeatureID IN (SELECT FeatureID FROM GroupFeatures)) THEN
INSERT INTO DeletedFeatures VALUES (OLD.FeatureID, OLD.FeatureName, OLD.FeatureDescription);
END IF;
END;
//
It is giving 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 '//' at line 8 "
Any ideas what the problem could be?
Have you checked by removing the semi-colon and add $$ after the END
DELIMITER $$
CREATE TRIGGER DeleteFeature
AFTER DELETE ON Features
FOR EACH ROW
BEGIN
IF (OLD.FeatureID IN (SELECT FeatureID FROM GroupFeatures)) THEN
INSERT INTO DeletedFeatures VALUES (OLD.FeatureID, OLD.FeatureName OLD.FeatureDescription);
END IF;
END $$
DELIMITER ;
DELIMITER //
CREATE PROCEDURE Sample
BEGIN
DECLARE v_SQLSTR VARCHAR(800);
SET v_SQLSTR='Hi';
END;
//
DELIMITER ;
Error Details: Error Code: 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 'BEGIN DECLARE v_SQLSTR VARCHAR(800); SET
v_SQLSTR='Hi'; END' at line 2
I am new in MySQL. Please help.
Missed the brackets. Try this:
...
CREATE PROCEDURE Sample()
...
That is because you have a syntax error:
Add () to your procedure's name
Remove ; after the END keyword
Change your code to:
DELIMITER //
CREATE PROCEDURE Sample()
BEGIN
DECLARE v_SQLSTR VARCHAR(800);
SET v_SQLSTR='Hi';
END //
DELIMITER ;
To avoid further errors, you can check the official documentation.
I can't fint the error in this code? Preciate some help! I also wonder how put values into this stored procedure from PHP/SQL
"
-- SP create new article
DROP PROCEDURE IF EXISTS {$spCreateArticle};
DELIMITER //
CREATE PROCEDURE {$spCreateArticle}
(
IN articleUserId INT,
IN articleSubject CHAR(50),
IN articleText TEXT,
)
BEGIN
INSERT INTO {$tableArticle}
(articleUserId, articleSubject, articleText, articleDate)
VALUES
(spArticleUserId, spArticleSubject, spArticleText, NOW());
END //
DELIMITER ;
",
Error message:
Error code 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 // CREATE PROCEDURE PCreateArticle ( IN articleUserId INT, IN arti' at line 4)
Should IN articleUserId INT etc. instead be IN spArticleUserId INT etc?