y Posted February 16, 2012 Share Posted February 16, 2012 hi i made a procedure to add into two tables at once but i tried to trace it's errors to rollback and it not working as i supposed here is the procedure with the error handler create procedure sp_multi_insert (in p_name varchar(50),in p_address varchar(100),in p_telephone varchar(20),in p_notes varchar(100), out p_return_code tinyint unsigned) begin declare exit handler for sqlexception begin set p_return_code=1; rollback; end; declare exit handler for sqlwarning begin set p_return_code=2; rollback; end; declare exit handler for not found begin set p_return_code=3; rollback; end; start transaction; insert into emp(name) values(p_name); insert into emp_det(id,address,telephone,notes) values(last_insert_id(),p_address,p_telephone,p_notes); commit; set p_return_code=0; end but every time i tried to call the procedure even if i passed wrong params or null the return code comes back with 0 call sp_multi_insert('','','','',@x); select @x; no values returns form sqlwarning handler or sqlexceptions why ??? what's wrong with the procedure statment or the calling ??? or who to trace the bug and rollback ???? Quote Link to comment Share on other sites More sharing options...
y Posted February 17, 2012 Author Share Posted February 17, 2012 help plz Quote Link to comment Share on other sites More sharing options...
y Posted February 19, 2012 Author Share Posted February 19, 2012 up Quote Link to comment Share on other sites More sharing options...
fenway Posted February 20, 2012 Share Posted February 20, 2012 How are you tracing this? Usually one uses INSERTs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.