1

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

2
  • We are unable to recognize that which ELSE is for which IF. Commented Jul 12, 2013 at 10:37
  • Please add the complete error message Commented Jul 12, 2013 at 10:37

1 Answer 1

1

You missed a;

...
FROM tr_inventory WHERE (idms_unittype = inpt);
                                              ^------here
ELSE 
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.