Doubt about MYSQL Code + Delphi

Asked

Viewed 61 times

0

Follows the code:

  DModuleGrid.qtudo.close;
  DModuleGrid.qtudo.sql.clear;
  DModuleGrid.qtudo.sql.add('select numcupom from tabc460 where cderr <:mc');
  DModuleGrid.qtudo.parambyname('mc').asinteger := 0;
  DModuleGrid.qtudo.open;

  if DModuleGrid.qtudo.recordcount > 0 then
  begin
    DModuleGrid.qres2.close;
    DModuleGrid.qres2.sql.clear;
    DModuleGrid.qres2.sql.add('delete from tdcupant where impcaixa = '+
      QuotedStr(impcaixa)+' and dtcompra between :dini and :dfim');
    DModuleGrid.qres2.parambyname('dini').asdate := date1;
    DModuleGrid.qres2.parambyname('dfim').asdate := date2;
    DModuleGrid.qres2.execsql;

    DModuleGrid.qtudo.close;
    DModuleGrid.qtudo.sql.clear;
    DModuleGrid.qtudo.sql.add('insert into tdcupant (select * from tabc460 '+
      'where dtcompra between :dini and :dfim) ');
    DModuleGrid.qtudo.parambyname('dini').asdate := date1;
    DModuleGrid.qtudo.parambyname('dfim').asdate := date2;
    DModuleGrid.qtudo.execsql;
  end;

So my question is whether delete, will only delete those he found in Recordcount, or delete everything he finds... Could someone enlighten me?

1 answer

1


delete from tdcupant Where impbox = '+ Quotedstr(impcaixa)+' and dtcompra between :Dini and :dfim

It will delete all records that:

  • Have the impcaixa equal to the informed
  • Whose dtCompra is greater than or equal to the parameter Dini and less than or equal to dfim

Having no relation to the Recordcount

To delete the records found on DModuleGrid.qtudo do:

while not DModuleGrid.qtudo.IsEmpty do
  DModuleGrid.qtudo.Delete;
  • It worked, buddy, now I get it right. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.