BEGIN
#Routine body goes here... I just do it ,even it's make me feel sick;
DECLARE daycount DOUBLE DEFAULT 0;
DECLARE monthcount DOUBLE DEFAULT 0 ;
DECLARE yearcount DOUBLE DEFAULT 0;
IF(last_interest_date is not null)THEN
IF(dates is not null)THEN
set daycount= (select SUM(account_balance*interest_rate/100/365) from account_balance_snap where dell_status = 0 and user_id =user_id and card_id = rowid);
update account_balance_snap SET dell_status = 1 where user_id =user_id and card_id = rowid;
set monthcount= (select sum(month_interest) from account_balance_month where dell_status = 0 and user_id =user_id and card_id = rowid);
update account_balance_month SET dell_status = 1 where user_id =user_id and card_id = rowid;
set yearcount= (select sum(year_interest) from account_balance_year where dell_status = 0 and user_id =user_id and card_id = rowid);
update account_balance_year SET dell_status = 1 where user_id =user_id and card_id = rowid;
set countInterest =daycount+monthcount+yearcount;
SELECT countInterest;
ELSE
END IF;
END
这样求出来的 countInterest 一直是空, 如果set daycount = 中加 @, 则会返回0; 求解!
解决办法就是通过判断NULL,赋值为0,进行准确计算!