Subject Re: [IBO] How to get the IBO object that caused the error?
Author Eric Handbury
--- In IBObjects@y..., "IMB T" <vatt@i...> wrote:
>
> Perhaps I wasn't clear in my message. For example I have the
following error
> caused by an TIBOQuery:
>
> Err: ISC ERROR CODE:335544349
>
> ISC ERROR MESSAGE:
> attempt to store duplicate value (visible to active transactions)
in unique
> index "IDXNAME"
>
> I need, as I stated before, the object(s) which are represented by
the above
> string(s) in order to issuse an appropiate centralized action
(based on the
> user choice), something like 'Do you want to rollback your edit?'

Here's one thing that I do for this type of checking. It doesn't
work in all situations, but...

I have some code in the Before-Insert Trigger like below:

FPKEY = 0;
SELECT FILEPERSONKEY FROM MBFILEPERSON WHERE FILEKEY=NEW.FILEKEY
AND PREFERRED=1 INTO FPKEY;
IF (FPKEY > 0) THEN
EXCEPTION MB_DUP; /* GENERATES MESSAGE "AC-DUP" */

And in my OnPostError (sorry for the BCB code), I have:

void __fastcall TFileDM::qrFilePersonPostError(TIB_Dataset *DataSet,
EIB_Error *E, TIB_DataAction &Action)
{
TStringList *tlist;
if (dynamic_cast<EIB_ISCError *> (E)->SQLCODE == -836) { //
Exception
// test ErrorMessage to see if it contains AC-Dup
tlist = dynamic_cast<EIB_ISCError *> (E)->ErrorMessage;
for(int i=0; i < tlist->Count; i++) {
if (tlist->Strings[i] == "AC-Dup") {
MessageDlg("A Preferred Contact Already Exists for this
File...", mtError, TMsgDlgButtons() << mbOK, 0);
break;
}
}
}
}

Once I get the AC-DUP error, I can do anything in terms of user-
interaction. (Here I just spit-out a message).

HTH. Eric.