I have dataset (Paradox table), where I defined secondary index which is
unique. In order to prevent user from entering duplicate values I wrote
OnPostError event handler where I check the error condition and if there
is Key violation (Error Code 9729 decimal) I inform the user in dialog
box about the error and set variable Action := daAbort. After that I
received BDE error "Index out of date".
I thought that if exception is raised the wrong action is not performed
so that error could not happen.
Where I am wrong? What is workaround in such a situation?
Another question: If index is "out of date" how to make it to be "in
date" ?
Thanx in advance.
Plamen Krastev <ra...@elits.rousse.bg> wrote in message
news:371F5081...@elits.rousse.bg...
I cannot remember was it "maintained", because I recreated it first
erasing it with the help of Database desktop and creating it again.
That index was created with Database desktop, and now I tried to create
one which is unique but not maintained and Database desktop denied such
operation, so the reason is not there.
Very strange is the fact that I have tried to reach that error condition
again for an hour and it didn't happen. I will continue testing.
Again to the second question: How to rebuild index which is "out of
date" programatically? Is the only possible way first to destroy it,
remove records with duplicated index values and create it again ?
Thanx for any suggestions.
Use the "AddIndex" and the "DeleteIndex" method for the TTable component.
Lookup in the delphi help file for the details on how to use them
,Aaron
>Another question: If index is "out of date" how to make it to be "in
>date" ?
Delete the index and recreate it.
--
Brian Bushay (TeamB)
Bbu...@NMPLS.com
No I haven't tried to clear the field before abort.
Actualy the code of event handler is short:
procedure TNomForm.NomenklPostError(DataSet: TDataSet; E:
EDatabaseError;
var Action: TDataAction);
var
ErrObject: TDBError;
begin
ErrObject := (E as EDBEngineError).Errors[0];
if ErrObject.ErrorCode = 9732 then MessageDlg('All fields must have
value',mtError,[mbOK],0)
else if ErrObject.ErrorCode = 9729 then MessageDlg('Field Code must
be unique',mtError,[mbOK],0)
else ShowMessage('ErrCode ' + IntToStr(ErrObject.ErrorCode));
Action := daAbort;
end;
After that "Index out of date" error I tried to recreate the problem
too, but I could not.
I will continue testing.