将查询结果分配给存储过程中的变量时出错

时间:2017-08-30 17:19:50

标签: mysql sql stored-procedures

我在向查询结果分配变量然后在表中插入该变量的值时遇到问题。该行被插入到表中,但'gPayRef'字段(应该包含变量的值)为空

这是我的代码: -

SET @eReceipt =
  (SELECT DISTINCT `gpayref`
  FROM `TRANSACTION`
  WHERE `ereceipt` = '12345');

INSERT INTO reversals (gpayref, reversalinitby, reversalinitdate, reason, status)
VALUES (@eReceipt,
    reversalinitby,
    Now(),
    reason,
      (SELECT id
       FROM `status`
       WHERE NAME = 'Reversal pending'));

SELECT Row_count() INTO res;      

0 个答案:

没有答案