[yunqa.de] DISQLite3 and Step/StepAndReset

  • From: Gregory Whitesides <whitesidesg@xxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Mon, 5 Dec 2011 04:33:50 -0800 (PST)

Hi,
I'm confused with using the Step/StepAndReset functions. Help please?
Let's assume, I want to update some records into a database:
  DB.StartTransaction();
  try
    for i := 0 to nxGrid.RowCount - 1 do
      if nxGrid.Selected[i] then begin
        Stmt := DB.Prepare16('UPDATE session SET vis=? WHERE rowid=?');
        try
          Stmt.Bind_Int(1, 0);                           // vis = FALSE
          Stmt.Bind_Int(2, nxGrid.Cell[0, i].AsInteger); // rec ID
          Stmt.StepAndReset; // or I should use Step???
        finally
          Stmt.Free;
        end;
      end;

    DB.Commit;
  except
    DB.Rollback;   
    raise;
  end;

and what about:

  DB.StartTransaction();
  try
    Stmt := DB.Prepare16('UPDATE session SET vis=? WHERE rowid=?');
    try
      for i := 0 to nxGrid.RowCount - 1 do
        if nxGrid.Selected[i] then begin
          Stmt.Bind_Int(1, 0);                           // vis = FALSE
          Stmt.Bind_Int(2, nxGrid.Cell[0, i].AsInteger); // rec ID
          Stmt.StepAndReset; // or I should use Step???
        end;
    finally
      Stmt.Free;
    end;

    DB.Commit;
  except
    DB.Rollback;   
    raise;
  end;

What will be the most correct way?

BR,
Greg
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: