2017-04-02 28 views
0

我運行mysql中執行以下步驟:Mysql的列數不匹配值計數(但它確實!)

create procedure addSavingAccount(id int(10), account_number varchar(10)) 
begin 
insert into saving values(id,'savings', account_number, 0); 
end // 

然而,當我嘗試調用它,它給了我這個錯誤:

mysql> call addSavingAccount(103, 'B505'); 
ERROR 1136 (21S01): Column count doesn't match value count at row 1 

我檢查了任何可能與之鏈接的東西,包括觸發器。但一切似乎都應該起作用。這裏是我的觸發器的列表:

create trigger balance_change_saving after update on saving for each row 
begin 
if old.balance != new.balance 
then 

insert into balance_update_history values(null, 'saving', new.account_number, old.balance, new.balance, 
              (SELECT NOW()), (select USER())); 
end if; 
end// 

create trigger balance_insert_saving after insert on saving for each row 
begin 
insert into balance_update_history values(null, 'saving', new.account_number, 0, new.balance, (select now()), 
              (select user())); 
end // 


create trigger balance_delete_saving after delete on saving for each row 
begin 
insert into balance_update_history values(null, null, null, old.balance, null, 
             (SELECT NOW()), (select USER())); 
end // 

這裏是我定義表:

create table if not exists saving(account_number varchar(10) , customer_id int(10), balance decimal(8,2), primary key(account_number)); 

我只是真的想摸不着頭腦。

回答

0

有三列基於你的表創建語句,而不是四個。 (該插入的最後0是什麼?)

另外,在該過程中,看起來您的插入值相對於表創建順序而言是亂序的?因此,您可以重新排列插入值以匹配表,或者使用插入指定列。

+1

我不得不把我的手放在我的臉上一秒鐘。感謝您的幫助。 –

相關問題