New features and enhancements:
1. A new TpFIBScripter component has been added.
It has the following properties:
property Script:TStrings ; - stores a text of the script.
property Database: TpFIBDatabase; - stores the connection, where the script will be executed. You should not define this property if the script has the CREATE DATABASE command.
property Transaction: TpFIBTransaction ; - stores the transaction where the script will be executed. As the TpFIBScripter component can control transactions, you should not always define the Transaction: TpFIBTransaction property value.
property AutoDDL: boolean – defines whether to call Commit automatically after each DDL command when the script is being executed.
property Paused: Boolean – enables the developer to stop the script execution in TpFIBScripter event handlers.
property StopStatementNo – returns the number of the command where the user stopped the script execution.
TpFIBScripter methods:
Procedure Parse(Terminator: Char = ';') – parses the script, defined in the Script: TStrings property. The argument is the command separator (by default it is a semicolon “;”).
procedure ExecuteScript (FromStmt: integer = 1); - executes the script defined in the Script: TStrings property. The argument is the number of the command which starts the execution.
procedure ExecuteFromFile (const FileName: string;Terminator: Char = ';'); - executes the script stored in the external file FileName. The full script text is not loaded in memory, the file is read line by line before the complete command is formed. When the command is ready, it’s executed and it’s text is deleted from memory. This approach enables you to execute very huge scripts.
function GetStatement (StmtNo: integer; Text: TStrings): PStatementDesc – enables you to get information about the command by its number позволяет (you should call the Parse method before it). The function returns a pointer to the PStatementDesc structure, which stores information about the command.
TpFIBScripter events:
property BeforeStatementExecute: TOnStatementExecute;
property AfterStatementExecute: TOnStatementExecute;
where
TOnStatementExecute = procedure(Sender: TObject; Line: Integer; StatementNo: Integer; Desc: TStatementDesc; Statement: TStrings);
The events are called before/after the every command execution.
property OnExecuteError: TOnSQLScriptExecError;
where
TOnSQLScriptExecError = procedure(Sender: TObject; StatementNo: Integer; Line: Integer; Statement: TStrings; SQLCode: Integer; const Msg: string; var doRollBack: boolean; var Stop: Boolean) of object;
The event happens if the current command was executed with errors.
An example.
var scr: TpFIBScripter;
begin
scr := TpFIBScripter.Create(nil);
try
Scr.Script.Text := MyScriptText;
Scr.ExecuteScript;
finally
scr.Free;
end;
end;
2. Now TpFIBDataSet has new methods:
procedure DisableMasterSource;
procedure EnableMasterSource;
function MasterSourceDisabled:boolean;
They are used to activate/deactivate the master-detail mode temporarily. For example:
DetailDataSet.DisableMasterSource;
try
MasterDataSet.Edit;
MasterDataSet.FieldByName('ID').asInteger:=NewValue;
MasterDataSet.Post;
ChangeDetailDataSetLinkField(NewValue);
finally
DetailDataSet.EnableMasterSource;
end;
and the detail dataset won’t reopen.
3. TpFIBDataSet has a new AutoUpdateOptions.UseExecuteBlock: Boolean property. It works only if CachedUpdates = True. If UseExecuteBlock is equal to True, then calling of ApplyUpdates and ApplyUpdToBase will generate queries with EXECUTE BLOCK. In other words changes made in the CachedUpdates mode will be sent to the database not for each record separately but in packages of 255 records.
4. Now FIBPlus supports CsMonitor (implemented by Yury Plotnikov). To use it you should activate the directive "CSMonitor" in FIBPlus.inc (only for the full FIBPlus version).
5. TpFIBDatabase has a new method: procedure ClearQueryCacheList.
6. The TFIBDataTimeField and TFIBTimeField fields have the ShowMsec: Boolean property. If it is set to True, time values with milliseconds will be shown in visual DB components.
7. The Locate method works significantly faster. To use this feature you should deactivate the directive {$DEFINE FAST_LOCATE} in FIBPlus.inc (only for the full FIBPlus version).
8. If the data is sorted, the Lookup method uses sorting to search for necessary values in TpFIBDateset.
9. Now if you use Select from procedure in Firebird 2.1 and input parameters are boolean or GUID, fields with corresponding types are created in TpFIBdataSet.
Bugs fixed:
1. Now UTF8 fields correctly work with InterBase 2007.
2. The CancelUpdates logic of TpFIBDataSet has been changed. When you called the CancelUpdates method in the CachedUpdates mode, FIBPlus restored field values which remained just before canceling. For example, if you first edited the record and then deleted it, you got changed field values instead of the original ones after calling CancelUpdates.
3. Unicode lookup-fields work correctly now.
4. An error in the TpFIBDataSet.CloneRecord method appeared if there were deleted records. Fixed.
5. The current record was positioned in the wrong place if the Refresh method was called automatically after record deleting (if the poRefreshDeleted option was active). Fixed.
6. Now internal transaction parameters work correctly for Firebird 2.1.
7. Now TSIBfibEventAlerter correctly registers events. This component operated improperly when TSIBfibEventAlerter and TpFIBDatabase were placed on different forms.
8. Now the procedure TFIBLargeIntField.SetVarValue(const Value: Variant) method operates rightly. It worked incorrectly when it had an input NULL value.
新特性和改進:
1. 增加了新的 TpFIBScripter 組件。
它有下列屬性:
屬性 Script:TStrings ; ——存儲腳本的文本。
屬性 Database: TpFIBDatabase; ——存儲腳本執行的連接。如果腳本有 CREATE DATABASE 命令,應該定義該屬性。
屬性 Transaction: TpFIBTransaction ; ——存儲腳本執行的事務。由于 TpFIBScripter 組件可以控制事務,不應該總是定義該 Transaction: TpFIBTransaction 屬性值。
屬性 AutoDDL: boolean ——定義是否當腳本被執行時,在每個 DLL 命令后自動調用 Commit。
屬性 Paused: Boolean ——使開發者在 TpFIBScripter 事件句柄中停止腳本執行。
屬性 StopStatementNo ——在用戶停止腳本執行處返回命令數。
TpFIBScripter 方法:
過程 Parse(Terminator: Char = ';') ——解析腳本,該腳本在 Script: TStrings 屬性中定義。參數是命令分隔符(默認為分號“;”)。
過程 ExecuteScript (FromStmt: integer = 1); ——執行腳本,該腳本在 Script: TStrings 屬性中定義。參數是開始執行的命令數。
過程 ExecuteFromFile (const FileName: string;Terminator: Char = ';'); ——執行腳本,該腳本存儲在外部文件 FileName。完整腳本不載入內存,在完整命令形成前,文件逐行讀出。當命令準備完畢,它被執行,然后命令文本從內存中被刪除。該方法使你可以運行十分大的腳本。
函數 GetStatement (StmtNo: integer; Text: TStrings): PStatementDesc ——使你通過它的數字 позволяет 獲得關于命令的信息(你應該在其之前調用 Parse 方法)。該函數返回一個指向 PStatementDesc 結構的指針,存儲關于命令的信息。
TpFIBScripter 事件:
屬性 BeforeStatementExecute: TOnStatementExecute;
屬性 AfterStatementExecute: TOnStatementExecute;
where
TOnStatementExecute = procedure(Sender: TObject; Line: Integer; StatementNo: Integer; Desc: TStatementDesc; Statement: TStrings);
這些事件在每個命令執行前/后調用。
屬性 OnExecuteError: TOnSQLScriptExecError;
where
TOnSQLScriptExecError = procedure(Sender: TObject; StatementNo: Integer; Line: Integer; Statement: TStrings; SQLCode: Integer; const Msg: string; var doRollBack: boolean; var Stop: Boolean) of object;
如果當前命令執行帶有錯誤,該事件產生。
一個例子。
var scr: TpFIBScripter;
begin
scr := TpFIBScripter.Create(nil);
try
Scr.Script.Text := MyScriptText;
Scr.ExecuteScript;
finally
scr.Free;
end;
end;
2. TpFIBDataSet 有新的方法:
過程 DisableMasterSource;
過程 EnableMasterSource;
函數 MasterSourceDisabled:boolean;
它們被用來暫時激活/解除激活 master-detail 模式。例如:
DetailDataSet.DisableMasterSource;
try
MasterDataSet.Edit;
MasterDataSet.FieldByName('ID').asInteger:=NewValue;
MasterDataSet.Post;
ChangeDetailDataSetLinkField(NewValue);
finally
DetailDataSet.EnableMasterSource;
end;
細節數據集不會重復打開。
3. TpFIBDataSet 有新的 AutoUpdateOptions.UseExecuteBlock: Boolean 屬性。它僅當CachedUpdates = True 時工作。如果 UseExecuteBlock 等于 True,調用 ApplyUpdates 和 ApplyUpdToBase 將會產生帶有 EXECUTE BLOCK 的查詢。也就是說,CachedUpdates 模式下做的改變將會發送到數據庫,不是單獨給每個記錄,而是給包含255個記錄的包。
4. FIBPlus 支持 CsMonitor (由Yury Plotnikov 實現)。要使用它,應當激活 FIBPlus.inc 中的“CSMonitor”指示(僅適用于完整的 FIBPlus 版本)。
5. TpFIBDatabase 有新的方法:過程 ClearQueryCacheList。
6. TFIBDataTimeField 和 TFIBTimeField 域有 ShowMsec: Boolean 屬性。如果設置為 True,帶有毫秒的時間值將會在視覺 DB 組件中顯示。
7. Locate 方法運行顯著加快。使用該特性,你應該取消激活 FIBPlus.inc 中的指示 {$DEFINE FAST_LOCATE} (僅適用于完整的 FIBPlus 版本)。
8. 如果數據被存儲,Lookup 方法使用排序在 TpFIBDateset 中尋找所需值。
9. 現在,如果你在 Firebird 2.1 中使用 Select from 過程,輸入布爾或 GUID 參數,對應類型的域將在 TpFIBdataSet 中創建。
錯誤修正:
1. UTF8 域在 InterBase 2007 中正常運行。
2. TpFIBDataSet 的 CancelUpdates 邏輯被改變。當在 CachedUpdates 模式中調用 CancelUpdates 方法時,FIBPlus 恢復取消前的域值。例如,如果你先編輯記錄之后刪除,你在調用 CancelUpdates 后獲得修改的值而不是原始值。
3. Unicode lookup-fields 正常工作。
4. 修正了 TpFIBDataSet.CloneRecord 方法中在有刪除的記錄時出現的錯誤。
5. 如果在刪除記錄后(如果 poRefreshDeleted 選項被激活)Refresh 方法自動調用,當前記錄被放置在錯誤位置 。已修正。
6. 內部事務參數在 Firebird 2.1 正常工作。
7. TSIBfibEventAlerter 正確注冊事件。當 TSIBfibEventAlerter 和 TpFIBDatabase 被放置到不同表單時,該組件曾不能正常運行。
8. 過程 TFIBLargeIntField.SetVarValue(const Value: Variant) 方法正確運行。當有 NULL 值輸入時,它曾不能正常工作。