Fórum sincronizar base de dados #561936
06/09/2016
0
preciso fazer sincronismo entre a base retaguarda e a pdv .
estou fazendo seguinte ex:
retaguarda.First;
while not retaguarda.Eof do begin
IBDataSet1.Close;
IBDataSet1.ParamByName('pcod').AsInteger:=retaguardaID_ESTOQUE.AsInteger;
IBDataSet1.Open;
if IBDataSet1.RecordCount>0 then begin
IBDataSet1.Edit;
IBDataSet1DESCRICAO.Text:=retaguardaDESCRICAO.Text;
IBDataSet1UNIDADE.Text:=retaguardaUNI_MEDIDA.Text;
IBDataSet1VALOR_VENDA.AsCurrency:=retaguardaPRC_VENDA.AsCurrency;
IBDataSet1BARRAS.Text:=retaguardaCOD_BARRA.Text;
IBDataSet1CARGA.Text:=DateToStr(date)+' as '+TimeToStr(time);
IBDataSet1.Post;
end;
if IBDataSet1.RecordCount=0 then begin
IBDataSet1.Append;
IBDataSet1COD.AsInteger:=retaguardaID_ESTOQUE.AsInteger;
IBDataSet1DESCRICAO.Text:=retaguardaDESCRICAO.Text;
IBDataSet1UNIDADE.Text:=retaguardaUNI_MEDIDA.Text;
IBDataSet1VALOR_VENDA.AsCurrency:=retaguardaPRC_VENDA.AsCurrency;
IBDataSet1BARRAS.Text:=retaguardaCOD_BARRA.Text;
IBDataSet1CARGA.Text:=DateToStr(date)+' as '+TimeToStr(time);
IBDataSet1.Post;
end;
mas quando se tem muitos registros fica muito lento , me ajudem com agumas dicas ?
Robson Pinheiro
Curtir tópico
+ 0Posts
06/09/2016
Raimundo Pereira
while not retaguarda.Eof do begin
// Tente trocar isso
IBDataSet1.Close;
IBDataSet1.ParamByName('pcod').AsInteger:=retaguardaID_ESTOQUE.AsInteger;
IBDataSet1.Open;
if IBDataSet1.RecordCount>0 then begin
// Até aqui
// Por este .
retaguarda.First;
IBDataSet1.open;// Deverá trazer todos os registros
IBDataSet1.fatchall;
while not retaguarda.Eof do begin
if IBDataSet1.locate('pcod',retaguardaID_ESTOQUE.AsInteger,[] )then
begin
IBDataSet1.Edit;
IBDataSet1DESCRICAO.Text:=retaguardaDESCRICAO.Text;
IBDataSet1UNIDADE.Text:=retaguardaUNI_MEDIDA.Text;
IBDataSet1VALOR_VENDA.AsCurrency:=retaguardaPRC_VENDA.AsCurrency;
IBDataSet1BARRAS.Text:=retaguardaCOD_BARRA.Text;
IBDataSet1CARGA.Text:=DateToStr(date)+' as '+TimeToStr(time);
IBDataSet1.Post;
end
else
begin
if not IBDataSet1.locate('pcod',retaguardaID_ESTOQUE.AsInteger,[] )then
begin
IBDataSet1.Append;
IBDataSet1COD.AsInteger:=retaguardaID_ESTOQUE.AsInteger;
IBDataSet1DESCRICAO.Text:=retaguardaDESCRICAO.Text;
IBDataSet1UNIDADE.Text:=retaguardaUNI_MEDIDA.Text;
IBDataSet1VALOR_VENDA.AsCurrency:=retaguardaPRC_VENDA.AsCurrency;
IBDataSet1BARRAS.Text:=retaguardaCOD_BARRA.Text;
IBDataSet1CARGA.Text:=DateToStr(date)+' as '+TimeToStr(time);
IBDataSet1.Post;
end;
end;
end;
Espero que ajude, pois o close e open constante da tabela deixará o processo lento.
Gostei + 0
06/09/2016
Robson Pinheiro
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)