Fórum Como deletar vários registros ao mesmo tempo ? #292587
22/08/2005
0
Gigatel
Curtir tópico
+ 0Posts
22/08/2005
Rjun
DELETE FROM Tabela WHERE Codigo = 10
Gostei + 0
22/08/2005
Gigatel
DELETE FROM Tabela WHERE Codigo = 10
Olha isso..esta é minha tabela..
DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE Codigo = 10
dá este erro..
[Error] Unit28.pas(444): ´(´ expected but identifier ´FROM´ found
Gostei + 0
22/08/2005
Rjun
1) Que banco você esta usando?
2) Qual a tecnologia de acesso?
3) Onde você pos essa instrução SQL?
Gostei + 0
22/08/2005
Gigatel
1) uso interbase,
2) uso uma IBquery + IBUpdat + Datasouce
3) coloquei no botão..
desculpe num sou muito bom em sql..se vc pudesse me ajudar me mostrando o o código inteiro..
este é o nome da tabela..ORCAMENTO_OFIC_ELET_ITENS ...
este é o nome que coloquei na IBquery....BD_ORCA_ITENS....
Vlw...
Gostei + 0
22/08/2005
Rjun
Crie uma Query. Vou chama-la de qryApaga. No botão, coloque o seguinte código:
qryApaga.SQL.Clear; qryApaga.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE Codigo = ´ + IntToStr(Codigo)); qryApaga.ExecSql;
Assim, isso é uma idéia. Se alguem que manja de IB puder ajudar mais, então poste aí.
Gostei + 0
22/08/2005
Gigatel
qryApaga.SQL.Clear; qryApaga.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE Codigo = ´ + IntToStr(Codigo)); qryApaga.ExecSql;
Montei o sódigo..
BD_ORCA_ITENS.SQL.Clear; BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE Codigo = ´ + IntToStr(BD_ORCA_ITENSGS_OOEI_CODIGO)); BD_ORCA_ITENS.ExecSql;
está dando este erro....
[Error] Unit28.pas(445): There is no overloaded version of ´IntToStr´ that can be called with these arguments
Gostei + 0
22/08/2005
Gigatel
O nome do componente ( ibquery )é.. BD_ORCA_ITENS ..
O nome do campo código é ... BD_ORCA_ITENSGS_OOEI_CODIGO ...
Só para eclarecimento..
Gostei + 0
22/08/2005
Rjun
Você esta tentando passar um TField como parâmetro em IntToStr. Coloque BD_ORCA_ITENSGS_OOEI_CODIGO.Value.
Eu evito fazer o q vc fez. Prefiro utilizar FieldByName.
BD_ORCA_ITENS.SQL.Clear; BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE Codigo = ´ + IntToStr(BD_ORCA_ITENS.FieldByName(´GS_OOEI_CODIGO´).Value)); BD_ORCA_ITENS.ExecSql;
Gostei + 0
23/08/2005
Gigatel
BD_ORCA_ITENS.SQL.Clear; BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE Codigo = ´ + IntToStr(BD_ORCA_ITENS.FieldByName(´GS_OOEI_CODIGO´).Value)); BD_ORCA_ITENS.ExecSql;
o campo em questão estva errado...agora está o código com os campos certos...
BD_ORCA_ITENS.SQL.Clear; BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE GS_OOEI_CODACES = ´ + IntToStr(BD_ORCA_ITENS.FieldByName(´GS_OOEI_CODACES´).Value)); BD_ORCA_ITENS.ExecSql;
Mas está dando este erro..
Project Teste.exe raised execption class EVariantTyeCastError..Não é possivel converter tipo de variant (null) em tipo (integer)...[/img]
Gostei + 0
23/08/2005
Imoreira
BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE GS_OOEI_CODACES = ´ + quotedstr(BD_ORCA_ITENS.FieldByName(´GS_OOEI_CODACES´).asString));
BD_ORCA_ITENS.ExecSql;
Gostei + 0
23/08/2005
Gigatel
Tá complicado amigo...hehehehe..tem que rir pra naum chorar...agora deu este erro..
exception class EIBInterbaseError with message..erro de conversão da string..
Gostei + 0
23/08/2005
Gandalf.nho
BD_ORCA_ITENS.SQL.Clear; BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE GS_OOEI_CODACES = :vGS_OOEI_CODACES´); BD_ORCA_ITENS.ParamByName(´vGS_OOEI_CODACES´).AsInteger := BD_ORCA_ITENSGS_OOEI_CODACES.Value; BD_ORCA_ITENS.ExecSql;
Gostei + 0
23/08/2005
Jujan
IBQuery1.sql.clear;
IBQuery1.sql.add(´delete from <nome_da_tabela>´);
IBQuery1.sql.add(´where <nome_do_campo> like´+QuotedStr(edit1.text));
try
IBQuery1.open;
except
end;
Gostei + 0
23/08/2005
Gigatel
BD_ORCA_ITENS.SQL.Clear; BD_ORCA_ITENS.SQL.Add(´DELETE FROM ORCAMENTO_OFIC_ELET_ITENS WHERE GS_OOEI_CODACES = :vGS_OOEI_CODACES´); BD_ORCA_ITENS.ParamByName(´vGS_OOEI_CODACES´).AsInteger := BD_ORCA_ITENSGS_OOEI_CODACES.Value; BD_ORCA_ITENS.ExecSql;
Parece que está desligando a tabela e os ítens não apagam..más parou de dá erro...
Gostei + 0
23/08/2005
Gigatel
Onde este edit1 entraria na minha função...
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)