[firebase-br] RES: ERROR:violation of FOREIGN KEY constraint

Mauricio Zanatta (Yahoo) mauricio_zanatta em yahoo.com.br
Seg Out 10 09:33:08 -03 2011


Bom dia Paulo,
Você pode fazer via SQL, de pelo menos duas formas:

1) delete from tabelafilha 
   where campo_chaveprim_tabfilha = 
   (select campo_chaveprim_tabfilha from tabelafilha
   left join tabelapai on campo_chaveprim_tabpai = campo_chaveestr_tabfilha
   where campo_chaveprim_tabfilha is null);

2) delete from tabelafilha 
   where campo_chaveprim_tabfilha = 
   (select campo_chaveprim_tabfilha from tabelafilha
   where campo_chaveestr_tabfilha not in (select campo_chaveprim_tabpai from
tabelapai));

Obs.: o select com o not in é muuuiiitoooo mais demorado!

Espero ter ajudado.
Att
Maurício Zanatta





Mais detalhes sobre a lista de discussão lista