Jump to content

tracing my procedure is not working probably


y

Recommended Posts

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 ????

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.