i have some problem regarding my mysql stored procedure, the mysql always shows up error 1064, error mysql syntax. where i was wrong?
我有一些关于我的mysql存储过程的问题,mysql总是显示错误1064,错误mysql语法。哪里我错了?
DELIMITER $$
USE `itin`$$
DROP PROCEDURE IF EXISTS `sp_Transaction`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_Transaction`(IN inpt TINYINT(4), IN inpt2 TINYINT(4))
BEGIN
IF((inpt = 0) AND (inpt2 = 0)) THEN
SELECT idtr_inventory, showStatus(idms_status) AS idms_status, showLocation(idms_location) AS idms_location
, showUnitType(idms_unittype) AS idms_unittype, USER, user_email
, showDepartment(idms_department) AS idms_department, asset_tag, sn, brand, model, showBBUser(bb_user) AS bbUser
, dt_purchase, warranty, dt_warranty_exp, nm_computer, ip_address, remarks
FROM tr_inventory;
ELSE IF(inpt = 0) THEN
SELECT idtr_inventory, showStatus(idms_status) AS idms_status, showLocation(idms_location) AS idms_location
, showUnitType(idms_unittype) AS idms_unittype, USER, user_email
, showDepartment(idms_department) AS idms_department, asset_tag, sn, brand, model, showBBUser(bb_user) AS bbUser
, dt_purchase, warranty, dt_warranty_exp, nm_computer, ip_address, remarks
FROM tr_inventory WHERE (idms_location = inpt2);
ELSE IF(inpt2 = 0) THEN
SELECT idtr_inventory, showStatus(idms_status) AS idms_status, showLocation(idms_location) AS idms_location
, showUnitType(idms_unittype) AS idms_unittype, USER, user_email
, showDepartment(idms_department) AS idms_department, asset_tag, sn, brand, model, showBBUser(bb_user) AS bbUser
, dt_purchase, warranty, dt_warranty_exp, nm_computer, ip_address, remarks
FROM tr_inventory WHERE (idms_unittype = inpt)
ELSE
SELECT idtr_inventory, showStatus(idms_status) AS idms_status, showLocation(idms_location) AS idms_location
, showUnitType(idms_unittype) AS idms_unittype, USER, user_email
, showDepartment(idms_department) AS idms_department, asset_tag, sn, brand, model, showBBUser(bb_user) AS bbUser
, dt_purchase, warranty, dt_warranty_exp, nm_computer, ip_address, remarks
FROM tr_inventory WHERE (idms_unittype = inpt) AND (idms_location = inpt2);
END IF;
END IF;
END IF;
END$$
DELIMITER ;
is it wrong in the end if statement? if yes, where i need to place? thanks.
如果声明到底是错的吗?如果是的话,我需要放在哪里?谢谢。
error: Query : CREATE DEFINER=root
@localhost
PROCEDURE sp_Transaction
(in inpt tinyint(4), IN inpt2 TINYINT(4)) begin if((inpt = 0) AND... 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 'else
错误:查询:CREATE DEFINER = root @ localhost PROCEDURE sp_Transaction(inpt tinyint(4),IN inpt2 TINYINT(4))if if((inpt = 0)AND ...错误代码:1064 SQL中有错误语法;检查与您的MySQL服务器版本对应的手册,以便在'else附近使用正确的语法
1 个解决方案
#1
1
You missed a;
你错过了;
...
FROM tr_inventory WHERE (idms_unittype = inpt);
^------here
ELSE
...
#1
1
You missed a;
你错过了;
...
FROM tr_inventory WHERE (idms_unittype = inpt);
^------here
ELSE
...