各位大牛,我近来刚学数据库,但编程还相当察,下面是我的一个代码,但老是出错:
delimiter $$

create     procedure withdraw(in account_number char(10),in amount numeric(16,2))
begin 
    declare newbalance numeric(16,2);
    select     balance into newbalance
    from     account
    where     account.account_number=account_number;

    set    newbalance=newbalance-amount;
    if(newbalance<0)
        begin
            newbalance=0;
        end
    end if

    update     account
    set     balance=balance-newbalance
    where     account.account_number=account_number;

end$$
delimiter ;

出错提示是:
Error Code : 1064
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 'begin
            newbalance=0;
        end
    end if
    update     account
    set     balance=balance-newb' at line 7
(0 ms taken)

用的软件是mysql5