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 ;
如果声明到底是错的吗?如果是的话,我需要放在哪里?感谢。
错误:
查询:CREATE DEFINER = root
@ localhost
程序sp_Transaction
(inpt tinyint(4),IN inpt2 TINYINT(4))if if((inpt = 0)AND ...
错误代码:1064
您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以便在'else
答案 0 :(得分:1)
您错过了;
...
FROM tr_inventory WHERE (idms_unittype = inpt);
^------here
ELSE
...