MySQL Forums
Forum List  »  Triggers

copy all values of fields on Update
Posted by: Edvaldo Panta
Date: May 22, 2006 09:09AM

My problem is...
I have 2 tables, lojas and lojas_cp. So, i created this trigger to make a automatic update in table lojas_cp. But when i change just one field on table lojas... the others fields of table lojas_cp are changed too and it receive value default of table.

Anybody knows .. how i can solver the problem.

Create trigger updateLojas after update on producao.lojas
for each row begin
update test.lojas_cp set loja_nome = new.loja_nome,loja_cnpj = new.loja_cnpj where loja_numero = new.loja_numero;

if (row_count() = 0) then

insert into test.lojas_cp set loja_numero = new.loja_numero,loja_nome = new.loja_nome,loja_cnpj = new.loja_cnpj;

end if;

END |



Edited 1 time(s). Last edit at 05/22/2006 09:11AM by Edvaldo Panta.

Options: ReplyQuote


Subject
Views
Written By
Posted
copy all values of fields on Update
6487
May 22, 2006 09:09AM


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.