Relacionar duas tabelas em um UPDATE
13/10/2004
0
======================
XXX XXX1
Chave1 Not Null Chave1 Not Null
Chave2 Not Null Chave2 Not Null
Chave3 Not Null Chave3 Not Null
Chave4 Not Null Chave4 Not Null
Chave5 Not Null
Dados1 Dados1
Dados2 Dados2
Dados3 Dados3
======================
Eu posso ter UM registro na XXX (Primeira Tabela) e varios registro na XXX1 (Segunda Tabela), porque só ira mudar o CHAVE5.
Eu estou precisando atualizar todos os campos (DADOS1,DADOS2,DADOS3) da XXX (Primeira Tabela) na XXX1 (Segunda Tabela).
Eu ateh consegui fazer isto por PROCEDURE mais como tenho 210 mil registros esta demorando quase 10 horas para atualizar todos, eu andei pesquisando, existe um comando para relacionar tabelas em bancos chamado INNER JOIN, mais infelizmente não funciona em ORACLE.
Atenciosamente,
Rodrigo Torres
Programador
[b:7ea7118fdf]Título editado. Removido o ´HELP-ME,´[/b:7ea7118fdf]
Sandra/Moderação
Rodrigo Torres
Posts
13/10/2004
Gandalf.nho
Uso de termo apelativo ´HELP-ME´
Para maiores esclarecimentos pode mandar-me uma [url=http://delphiforum.icft.com.br/forum/privmsg.php?mode=post&u=8378]Mensagem Particular[/url].
13/10/2004
Motta
begin for r in (select * from xxx) loop update xxx1 set campo1 = r.campo1, campo2 = r.campo2 ... where chave1 = r.chave1 and chave2 = r.chave2 ...; end loop; end;
13/10/2004
Rodrigo Torres
begin for r in (select * from xxx) loop update xxx1 set campo1 = r.campo1, campo2 = r.campo2 ... where chave1 = r.chave1 and chave2 = r.chave2 ...; end loop; end;
Eu estava usando uma parecida, usando cursor, mais estava demorando 10 horas, é um absurdo para 200 mil registros, vou tentar seu metodo, pra ver se eh mais rapido, ja ja postarei a resposta.
Vlw,
[]´s
13/10/2004
Motta
13/10/2004
Fernando-bh
Não precisa fazer um PL para resolver esse problema. Você pode usar isso:
update xxx1 ext set (ext.dados1,ext.dados2,ext.dados3) = (select int1.dados1, int1.dados2, int1.dados3 from xxx1 int1 where int1.chave1 = ext.chave1 and int1.chave2 = ext.chave2 and int1.chave3 = ext.chave3 and int1.chave4 = ext.chave4)
Um abraço,
13/10/2004
Fernando-bh
Desculpe, pois cometi um engano.
Por favor, substitua o trecho ´from xxx1 int´ por xxx. O comando a seguir já está corrigido.
update xxx1 ext set (ext.dados1,ext.dados2,ext.dados3) = (select int1.dados1, int1.dados2, int1.dados3 from xxx int1 where int1.chave1 = ext.chave1 and int1.chave2 = ext.chave2 and int1.chave3 = ext.chave3 and int1.chave4 = ext.chave4)
Um abraço,[/code]
14/10/2004
Motta
set (ext.dados1,ext.dados2,ext.dados3) = (select int1.dados1, int1.dados2, int1.dados3
from xxx int1
where int1.chave1 = ext.chave1
and int1.chave2 = ext.chave2
and int1.chave3 = ext.chave3
and int1.chave4 = ext.chave4)
não vai fazer com que sejam atualizadas TODAS as colunas de xxx1 ?!
não tem WHERE CONDITION ?!
não entendi, confeso.
15/10/2004
Rodrigo Torres
Não testei a SQL de update que o Fernando-BH postou, MUITO obrigado a todos por ajudarem.
Muito Agradecido,
Rodrigo Torres
Programador
Clique aqui para fazer login e interagir na Comunidade :)