Deletar em cascata II

Delphi

14/10/2003

Alguém tem um código para excluir registros de uma table filha ligados em um registro da table mãe ?
Estou usando uma banco Paradox

CBier


Cbier

Cbier

Curtidas 0

Respostas

Balceiro

Balceiro

14/10/2003

cara eu faço o seguinte:


with tabelapai do
first;
   begin
   whith tabelafilho do
   first;
   begin
     while not eof fo
        begin
             delete;
        end;
   end;
delete;
next;
end;


funciona 100¬ de uma maneira muito rápida...


qualquer dúvida mail-me balceiro@bol.com.br....


GOSTEI 0
Balceiro

Balceiro

14/10/2003

delculpe, estava meio bebado quando escrevi este código, agora segue o correto...


with tabelapai do 
begin 
     first; 
     while not eof do
     begin
          with tabelafilha do
          begin
               first;
               while not eof do
               begin
                   delete;
               end;
          end;
     delete; 
     end;
end;



agora acho que funciona testa ai....


GOSTEI 0
Cbier

Cbier

14/10/2003

valeu. vou fazer o teste.


GOSTEI 0
POSTAR