Subject | Re: [IBO] How to get the IBO object that caused the error? |
---|---|
Author | Eric Handbury |
Post date | 2002-10-03T22:03:48Z |
--- In IBObjects@y..., "IMB T" <vatt@i...> wrote:
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.
>following error
> Perhaps I wasn't clear in my message. For example I have the
> caused by an TIBOQuery:in unique
>
> Err: ISC ERROR CODE:335544349
>
> ISC ERROR MESSAGE:
> attempt to store duplicate value (visible to active transactions)
> index "IDXNAME"the above
>
> I need, as I stated before, the object(s) which are represented by
> 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.