Oi pessoal! deu branco hó. Preciso apagar todos os registro?

Delphi

28/08/2003

Tenho um banco de dados linkado a outro ex.
tb_escritorio e tb_material

Eu quero fazer uma rotina que apague todos os registro da tb_material que está vinculado a tb_escritorio. eu não me lembro

tb_material.prior;

while to tb_escritorio do
begin
tb_material.delete;
tb_material.next;
end;

Preciso desta dica ´URGENTE´.


Machado

Machado

Curtidas 0

Respostas

Luciano Pimenta®

Luciano Pimenta®

28/08/2003

Faça uma instrução SQL:
DELETE FROM tb_material
WHERE cod_material in (SELECT cod_material FROM tb_escritorio)


GOSTEI 0
Machado

Machado

28/08/2003

Faça uma instrução SQL: DELETE FROM tb_material WHERE cod_material in (SELECT cod_material FROM tb_escritorio)

Meu banco de dados é paradox e prefiro não entrar muito neste negocio de sql que eu uso apenas para gerar relatórios. não tem outro exemplo?


GOSTEI 0
Machado

Machado

28/08/2003

While not Table1.isEmpty do
Table1.Delete;

prontinho!! hehehe


GOSTEI 0
Bacalhau

Bacalhau

28/08/2003

Se não houver indices secundários para facilitar, escreve:

table1.first;
while not table1eof do
begin
if <material pertence ao escritório>
then table1.delete
else table1.next;
end;


GOSTEI 0
POSTAR