Re: Loop Trigger

2006-04-21 Thread Jeff Smelser
On Wednesday 19 April 2006 11:10, Lucas Vendramin wrote:
 Hi all.
 I am creating a trigger that update the some table witch call it.
 Ex:
 create table t1 (
  id int, name varchar(50), c int default 0, father int,
  primary key(id),
  index (father),
  foreign key (father) references t1(id) on update restrict on delete
 restrict );
 create trigger tg_t1
 before update on t1
 for each row
 begin
  update t1 set c=c+1 where father=NEW.id;
 end;

set NEW.c = NEW.c + 1;

or whatever. You dont update on a before trigger.. 

Jeff


pgpeUL5J7xa3l.pgp
Description: PGP signature


Loop Trigger

2006-04-19 Thread Lucas Vendramin
Hi all.
I am creating a trigger that update the some table witch call it.
Ex:
create table t1 (
 id int, name varchar(50), c int default 0, father int,
 primary key(id),
 index (father),
 foreign key (father) references t1(id) on update restrict on delete restrict
);
create trigger tg_t1
before update on t1
for each row
begin
 update t1 set c=c+1 where father=NEW.id;
end;

Something like it... I want to update some colums witch records are referencing 
by the father record.
But when I update the mysql returns: Can't update table 't1' in stored 
function/trigger because it is already used by statement which invoked this 
stored function/trigger

Why I cant make a trigger that update the some table that invoke the trigger???
How can I build it?

Thanks.
Lucas Vendramin

Re: Loop Trigger

2006-04-19 Thread Lucas Vendramin

Hi.
Anyone know how to create a trigger that update the table that invoked it?

--
Hi all.
I am creating a trigger that update the some table witch call it.
Ex:
create table t1 (
id int, name varchar(50), c int default 0, father int,
primary key(id),
index (father),
foreign key (father) references t1(id) on update restrict on delete 
restrict

);
create trigger tg_t1
before update on t1
for each row
begin
update t1 set c=c+1 where father=NEW.id;
end;

Something like it... I want to update some colums witch records are 
referencing by the father record.
But when I update the mysql returns: Can't update table 't1' in stored 
function/trigger because it is already used by statement which invoked this 
stored function/trigger


Why I cant make a trigger that update the some table that invoke the 
trigger???

How can I build it?

Thanks.
Lucas Vendramin 



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]