MySQL Forums
Forum List  »  MySQL Query Browser

Re: Query Help Needed
Posted by: irek kordirko
Date: February 27, 2012 05:05PM

No, it won't work.

create table a(
  id int primary key,
  name varchar(100)
);

insert into a values( 1, 'name 1' ), ( 2, 'name 2');

delimiter $$
drop procedure if exists upd_a $$
create procedure upd_a( i_name varchar(100))
begin
  update a set name = i_name where id = 1;
end;
$$

create trigger upd_a_trig
after update on a
for each row
begin
  call upd_a( 'new name' );
end;
$$

delimiter ;

mysql> update a set name = 'xx' where id = 2;
ERROR 1442 (HY000): Can't update table 'a' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

Options: ReplyQuote


Subject
Written By
Posted
February 25, 2012 02:48PM
February 26, 2012 10:39AM
February 26, 2012 06:46PM
February 27, 2012 02:18PM
February 27, 2012 08:14AM
Re: Query Help Needed
February 27, 2012 05:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.