>From: Terry Johnson [mailto:[EMAIL PROTECTED]]
>
>I've had problems with record locking - when a background process is trying
>to update a database that some user somewhere has left open during an edit.

Shurely locking issues would only occur during an uncommitted transaction?

>That's more of an underlying database issue, but the upshot was dbaware
>controls could not be used.

If it really was a showstopper you could still have used ClientDataSets,
running dbaware controls off them.

>Then there's always the problems of queries -
>the drama involved in updating a record returned in a read-only result set,

There are various non-dramatic ways to skin the "read-only result set" cat.
Eg., using RequestLive and CachedUpdates true:

procedure TForm1.qComplexQueryAfterPost(DataSet: TDataSet);
begin
  qComplexQuery.ApplyUpdates;
end;

procedure TForm1.qComplexQueryAfterDelete(DataSet: TDataSet);
begin
  qComplexQuery.ApplyUpdates;
end;

procedure TForm1.qComplexQueryUpdateRecord(DataSet: TDataSet;
  UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);

  procedure SetParams;
  var i: integer;
  begin
    with qTemp do for i := 0 to Params.Count - 1 do begin
      Params[i].ParamType := ptInput;
      Params[i].DataType := DataSet.FieldByName(Params[i].Name).DataType;
      Params[i].Value := DataSet.FieldByName(Params[i].Name).Value;
    end;
  end;

begin
  inherited;
  Database1.StartTransaction;
  try
    with qTemp, SQL do begin
      Close;
      Clear;
      case UpdateKind of
        ukInsert: begin
          Add('insert into TABLE1');
          Add('  (COL1, COL2, ...)');
          Add('values');
          Add('  (:PAR1, PAR2, ...)');
          SetParams;
          ExecSQL;
          Clear;
          Add('insert into TABLE2');
          Add('  (COL1, COL2, ...)');
          Add('values');
          Add('  (:PAR1, PAR2, ...)');
          SetParams;
          ExecSQL;        
        end;
        ukModify: begin
           ...
        end;
        ukDelete: ...
      end;
    end;
    Database1.Commit;
    UpdateAction := uaApplied;
  except
    Database1.Rollback;
    raise;
  end;
end;

That's just a trivial example to show how easy it can be.  You can improve
on it a lot (especially to reduce its verboseness): generically pre-prepared
parameterised queries, UpdateSQLObjects, ClientDataSets, blah blah blah. :)
Still not nearly the effort required when you drop dbaware.

>and doing so in a way that is clean and intuitive to the user, and can be
>accomplished in a reasonable timeframe with large databases.

Hmmm... how does going non-dbaware deal with those issues any better?

Cheers,
Carl

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to