'systax error in stored procedures
In php-myadmin . while runnig this query I am getting it like ..Import has been successfully finished, 0 queries executed. (getpaywall.com_2013-06-16.sql)
But its not giving me that the procedures . please solve this issue:
DELIMITER $;
CREATE PROCEDURE `ISSUE_REFUND`(IN buyer_user_id INT, IN order_id INT, IN refund_amount DECIMAL(5,2), IN refund_feedback TEXT)
BEGIN
SET autocommit=0;
START TRANSACTION;
SELECT customer_user_id,paid_amount,status INTO @userid,@paidamount,@orderstatus FROM orders WHERE id=order_id;
IF @orderstatus='failed' OR @orderstatus='refunded' OR @orderstatus='partial_refunded' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Error: Order already refunded or failed!', MYSQL_ERRNO = 1004;
ROLLBACK;
ELSE
IF @userid=buyer_user_id THEN
IF refund_amount <= @paidamount THEN
IF refund_amount=@paidamount THEN
SET @type1='refunded';
ELSE
SET @type1='partial_refunded';
END IF;
UPDATE orders SET status=@type1,refunded_comment=refund_feedback,refunded_amount=refund_amount WHERE id=order_id;
COMMIT;
ELSE
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Error: Refund amount cannot be greater than paidamount!', MYSQL_ERRNO = 1005;
ROLLBACK;
END IF;
ELSE
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Error: Customer ID in orders does not match with given buyer_user_id!', MYSQL_ERRNO = 1003;
ROLLBACK;
END IF;
END IF;
END;$
DELIMITER ;$
and when i run it through terminal by using
mysql -u root -p paywall < getpaywall.com_2013-06-16.sql
i had an error which says
ERROR 1064 (42000) at line 2: 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 ' SET autocommit=0;
START TRANSACTION;
SELECT customer_user_id,paid_' at line 3
Solution 1:[1]
When you export a procedure then you will find username of the DB from where you have exported change that username.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Amit Garg |