操作数应包含1列存储过程

时间:2011-04-29 09:33:06

标签: mysql stored-procedures

我试图在一个程序中使用多个选择来分配变量的值。 但我得到这样的错误“操作数应该包含1列(s)” 这是我的代码:

DELIMITER $$

DROP PROCEDURE IF EXISTS `bankdb`.`charge` $$
CREATE PROCEDURE `bankdb`.`charge` ()
BEGIN
  DECLARE idcust_val INT;
  DECLARE balance_val FLOAT;
  DECLARE balance_val1 FLOAT;
  DECLARE balance_val2 FLOAT;
  DECLARE productCd_val VARCHAR(10);
  DECLARE productType_val VARCHAR(10);
  DECLARE no_more_rows INT DEFAULT 0;
  DECLARE num_rows INT DEFAULT 0;

  DECLARE col_cur CURSOR FOR
  select a.cust_id, a.avail_balance, a.product_cd, p.product_type_cd
  from account a, product p
   where a.product_cd = p.product_cd;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_rows = 1;

  OPEN col_cur;
  select FOUND_ROWS() into num_rows;

  read_loop: LOOP
  IF no_more_rows THEN
  CLOSE col_cur;
  LEAVE read_loop;
  END IF;
  FETCH col_cur INTO idcust_val, balance_val, productCd_val, productType_val;
  SELECT idcust_val, balance_val, productCd_val;
    IF productType_val = 'ACCOUNT' THEN
      IF productCd_val = 'SAV' || productCd_val = 'CD' THEN
        IF balance_val < 2000 THEN
              SELECT (balance_val-10) INTO balance_val;
        END IF;
      ELSE
        SELECT (balance_val+(balance_val*0,05)) INTO balance_val;
      END IF;
     ELSE
      SELECT (balance_val-(balance_val*0,1)) INTO balance_val;
    END IF;
  /*UPDATE account SET avail_balance = balance_val WHERE account_id = idcust_val;*/
  END LOOP read_loop;
END $$
DELIMITER ;

请帮忙!

1 个答案:

答案 0 :(得分:1)

更改小数点&#39;,&#39;到&#39;。&#39;

0,05 -> 0.05
0,1 - 0.1