1
votes

i have some problem regarding my mysql stored procedure, the mysql always shows up error 1064, error mysql syntax. where i was wrong?

   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

1
We are unable to recognize that which ELSE is for which IF. - Code Lღver
Please add the complete error message - juergen d

1 Answers

1
votes

You missed a;

...
FROM tr_inventory WHERE (idms_unittype = inpt);
                                              ^------here
ELSE 
...