this is my code:
DM->UTT2->StartTransaction();//UQRY3 and UniScript1 have a same UTT2
try
{
//Master Commit and return Primary key
DM->UQRY3->Close();
DM->UQRY3->SQL->Clear();
DM->UQRY3->SQL->Add("SELECT * FROM SP_ADD_RKD_M(:F_RKRQ,:F_HH,:F_PH,:F_DHSL,:F_FJH,:F_DH)");
DM->UQRY3->ParamByName("F_RKRQ")->Value=FormatDateTime("yyyy-MM-dd",DateTimePicker1->Date);
DM->UQRY3->ParamByName("F_HH")->Value=Edit1->Text;
DM->UQRY3->ParamByName("F_PH")->Value=Edit2->Text;
DM->UQRY3->ParamByName("F_DHSL")->Value=Edit3->Text;
DM->UQRY3->ParamByName("F_FJH")->Value=Edit4->Text;
DM->UQRY3->ParamByName("F_DH")->Value=Edit5->Text;
DM->UQRY3->Open();
int f_id=DM->UQRY3->FieldByName("F_ID1")->AsInteger;
UniScript1->Params->Clear();
for (int j=0;jParams->Add();
}
UniScript1->Params->Items[0]->Name="F_P_ID";
UniScript1->Params->Items[1]->Name="F_MC";
UniScript1->Params->Items[2]->Name="F_SL";
//Detail Commit
for (int i=1;iRowCount-1;i++)
{
UniScript1->SQL->Clear();
UniScript1->SQL->Add("INSERT INTO T_RKD_D(F_ID,F_P_ID,F_MC,F_SL) VALUES(Gen_ID(GEN_T_RKD_D_ID,1),:F_P_ID,:F_MC,:F_SL);");
UniScript1->Params->ParamByName("F_P_ID")->Value=f_id;
UniScript1->Params->ParamByName("F_MC")->Value=AdvStringGrid1->Cells[1];
UniScript1->Params->ParamByName("F_SL")->Value=AdvStringGrid1->Cells[2];
UniScript1->Execute();// have a Exception,but "catch(Exception &E)" Unable to catch the exception
}
//Transaction Commit
DM->UTT2->Commit();
Application->MessageBoxA("ok!","ok",MB_OK+64);
}
catch(Exception &E)
{
DM->UTT2->Rollback();
Application->MessageBoxA(E.Message.c_str(),"error",MB_OK+16);
return;
}
my problem:UniScript1->Execute() have a Exception,but "catch(Exception &E)" Unable to catch the exception,so than Master Commit,but Detail not Commit
Master/Detail Transaction UniScript1 and exception
-
AndreyZ
Hello,
Exceptions that can be raised during TUniScript execution are handled by the Application.HandleException method by default. To change such behaviour, you should use the TUniScript.OnError event handler in the following way:After this you will be able to catch all exceptions that can be raised during TUniScript execution.
Exceptions that can be raised during TUniScript execution are handled by the Application.HandleException method by default. To change such behaviour, you should use the TUniScript.OnError event handler in the following way:
Code: Select all
void __fastcall TForm1::UniScript1Error(TObject *Sender, Exception *E,
AnsiString SQL, TErrorAction &Action)
{
Action = eaFail;
}