Re: copy all values of fields on Update
Posted by:
Bob Field
Date: May 22, 2006 12:38PM
create trigger updateLojas after update on producao.lojas
for each row begin
set @stmt = 'update test.lojas_cp set ';
if new.loja_nome != old.loja_nome then
set @stmt = concat(@stmt, 'loja_nome = new.loja_name,');
end if;
if new.loja_cnpj != old.loja_cnpj then
set @stmt = concat(@stmt, 'loja_cnpj = new.loja_cnpj,');
end if
set @stmt = left(@stmt, length(@stmt)-1));
set @stmt = concat(@stmt, ' where loja_numero = new.loja_numero';
prepare stmt1 from @stmt;
execute stmt1;
deallocate prepare stmt1;
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|
Subject
Views
Written By
Posted
6469
May 22, 2006 09:09AM
2483
May 22, 2006 10:18AM
2504
May 22, 2006 10:29AM
Re: copy all values of fields on Update
2344
May 22, 2006 12:38PM
2699
May 22, 2006 05:08PM
2007
May 23, 2006 08:04AM
2256
May 23, 2006 10:32AM
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.