Good afternoon,
How do I update with inner join, since I need to change the field idnaoleitura = 24 to idnaoleitura = 0 where the idrota in (35,45,48,53,60,68,70,79), remembering the idrota is in another table.
The calculating_table_count table has the field idnaoleitura The data_calculation table has the idrota field The keys are the fields: IDUC
calculo_leituras_ucb.iduc calculo_dados.iduc
Follow the code below.
begin
execute immediate 'alter table calculo_leituras_ucb disable all triggers';
execute immediate 'alter table calculo_dados disable all triggers';
UPDATE calculo_leituras_ucb
SET calculo_leituras_ucb.idnaoleitura = 0
from calculo_leituras_ucb
inner join calculo_dados on calculo_leituras_ucb.iduc = calculo_dados.iduc
where calculo_leituras_ucb.ano_mes = ('01/07/2014')
and calculo_dados.idrota in (35,45,48,53,60,68,70,79)
and calculo_leituras_ucb.idnaoleitura = 24 ;
commit;
execute immediate 'alter table calculo_leituras_ucb enable all triggers';
execute immediate 'alter table calculo_dados enable all triggers';
exception when others then
rollback;
execute immediate 'alter table Calculo_leituras_ucb enable all triggers';
execute immediate 'alter table calculo_dados enable all triggers';
RAISE_APPLICATION_ERROR(-20000,'tem erro no script >:( !!!.'|| sqlerrm(sqlcode));
end;