存储过程中的语法错误

时间:2013-06-17 04:00:43

标签: mysql stored-procedures mysqli phpmyadmin

在php-myadmin中。而runnig这个查询我得到它像..Import已成功完成,0执行查询。 (getpaywall.com_2013-06-16.sql)

但是它没有给我那个程序。请解决这个问题:

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 ;$

当我通过终端使用

运行它时
  

mysql -u root -p paywall&lt; getpaywall.com_2013-06-16.sql

我有一个错误,上面写着

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

1 个答案:

答案 0 :(得分:0)

导出过程后,您将找到导出更改该用户名的数据库的用户名。