Board index » delphi » Referential Integrity - PLEASE HELP

Referential Integrity - PLEASE HELP

HI,
I've got various Master-Detail-Detail tables in an application and need to
modify the tables.
I'd like to do this programmatically, but can't find any way to check out
the referential integrity/dependant table constraints within the program.
I'm using Paradox as the database and Paradox 7 or Database Desktop both let
be examine/change the constraints OK but what properties are there that
expose them??

If anyone has any ideas I'd be most grateful.

In anticipation,

Dave Johnson

 

Re:Referential Integrity - PLEASE HELP


You will probably find some most useful examples installed together with
Delphi in
Borland\Delphi 3\Demos\Db\DBerrors\Dberrors.dpr
the table event:     orders.ondeleteerror

 procedure TDM.OrdersDeleteError(DataSet: TDataSet; E: EDatabaseError;
    var Action: TDataAction);
  begin
    if E is EDBEngineError then
      if (E as EDBEngineError).Errors[0].Errorcode = eDetailsExist then
       {can not delete due to referential integrities}
      begin  
        if MessageDlg('Delete this order and related items?',
mtConfirmation,
          [mbYes, mbNo], 0) = mrYes then
        begin
          {Delete related records in linked 'items' table}
           {which means deleting 'detail' table records before deleting }
            { 'master' table records}
          while Items.RecordCount > 0 do
            Items.delete;
          {Finally,delete this record}
          Action := daRetry;
        end else Abort;
      end;
  end;

--
Mariusz Jedrzejowski
  messages send to
mruczus(*)nova.kki.krakow.pl
where (*) = @

Other Threads