Subject | [IBO] Problem executing a Script |
---|---|
Author | Enrico Raviglione |
Post date | 2004-01-20T08:44:32Z |
Hi to all,
i have some stranges problem updating a database with a SQL Script on
FireBird v.1.5 Server (RC4 or RC7).
For update my DataBase (and Database installed to my costumers) my
application run some scripts using a TIB_Script component.
In some case (to some costumers) and randomly the update process stop
with error. Then if i re-do it the process can terminate succesfully.
I don't understand why, below the sequence of the update operation.
The sequence are this:
1) log in as SYSDBA
2) verify who no other user are logged on to my DB
3) Load the first instruction of the script (at ex. Alter Stored
Procedure ..... ) and Execute it;
4) Load the second instruction of the script (at ex. Alter Stored
Procedure ..... ) and Execute it;
5) Load the third instruction of the script (at ex. Alter Stored
Procedure ..... ) and Execute it;
6) etc....
7) at the end of update start my updated application.
Any step (3, 4, 5) are isolated using Transaction and the TIB_Script
event in this manner:
1) On TIB_Script->BeforeExecute i call StartTransaction();
2) On TIB_Script->AfterExecute i test if the Script are runned correctly
then i call the Commit() or terminate with a Rollback().
Below the procedures attached to the event:
void __fastcall MyClass::ScriptBeforeExecute(TObject *Sender)
{
ScriptTransaction->StartTransaction();
Script->SQL->Assign( FSQLScriptLines );
Versione->Caption = FSQLScriptLines->Strings[0].Trim();
ProgressBar->Max = Script->SQL->Count-1;
ProgressBar->Position = 0;
Visible = true;
}
//----------------------------------------------------------------------
-----
void __fastcall MyClass::ScriptAfterExecute(TObject *Sender)
{
if ( Script->ExecutingFailed )
{
ScriptTransaction->Rollback();
Application->MessageBox("\r\n Errors updating database!
\r\n","ATTENTION",MB_OK);
Application->Terminate();
}
else if ( Script->ExecutingAborted )
{
ScriptTransaction->Rollback();
Application->MessageBox("\r\n Errors updating database!
\r\n","ATTENTION",MB_OK);
Application->Terminate();
}
else
ScriptTransaction->Commit();
}
//----------------------------------------------------------------------
-----
Best regards,
Enrico Raviglione
i have some stranges problem updating a database with a SQL Script on
FireBird v.1.5 Server (RC4 or RC7).
For update my DataBase (and Database installed to my costumers) my
application run some scripts using a TIB_Script component.
In some case (to some costumers) and randomly the update process stop
with error. Then if i re-do it the process can terminate succesfully.
I don't understand why, below the sequence of the update operation.
The sequence are this:
1) log in as SYSDBA
2) verify who no other user are logged on to my DB
3) Load the first instruction of the script (at ex. Alter Stored
Procedure ..... ) and Execute it;
4) Load the second instruction of the script (at ex. Alter Stored
Procedure ..... ) and Execute it;
5) Load the third instruction of the script (at ex. Alter Stored
Procedure ..... ) and Execute it;
6) etc....
7) at the end of update start my updated application.
Any step (3, 4, 5) are isolated using Transaction and the TIB_Script
event in this manner:
1) On TIB_Script->BeforeExecute i call StartTransaction();
2) On TIB_Script->AfterExecute i test if the Script are runned correctly
then i call the Commit() or terminate with a Rollback().
Below the procedures attached to the event:
void __fastcall MyClass::ScriptBeforeExecute(TObject *Sender)
{
ScriptTransaction->StartTransaction();
Script->SQL->Assign( FSQLScriptLines );
Versione->Caption = FSQLScriptLines->Strings[0].Trim();
ProgressBar->Max = Script->SQL->Count-1;
ProgressBar->Position = 0;
Visible = true;
}
//----------------------------------------------------------------------
-----
void __fastcall MyClass::ScriptAfterExecute(TObject *Sender)
{
if ( Script->ExecutingFailed )
{
ScriptTransaction->Rollback();
Application->MessageBox("\r\n Errors updating database!
\r\n","ATTENTION",MB_OK);
Application->Terminate();
}
else if ( Script->ExecutingAborted )
{
ScriptTransaction->Rollback();
Application->MessageBox("\r\n Errors updating database!
\r\n","ATTENTION",MB_OK);
Application->Terminate();
}
else
ScriptTransaction->Commit();
}
//----------------------------------------------------------------------
-----
Best regards,
Enrico Raviglione