Doubt on MYSQL + Delphi Code

0

Follow 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 if my delete , will delete only those he found in Recordcount , or will delete everything he finds ... Could someone clarify me?

    
asked by anonymous 02.07.2014 / 13:41

1 answer

1
  

delete from tdcupant where impcaixa = '+        QuotedStr (impcaixa) + 'and dtcompra between: dini and: dfim

It will delete all records that:

  • Have impcount as reported
  • Whose dtCompra is greater than or equal to the dini parameter and less than or equal to dfim

Having no relation to Recordcount

To delete the records found in DModuleGrid.qtudo do:

while not DModuleGrid.qtudo.IsEmpty do
  DModuleGrid.qtudo.Delete;
    
02.07.2014 / 13:46