Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Incident Reports » Incident Reports Reported for Version 3.21 » View Incident Report |
Serious |
Reported By: Ole Willy Tuv Reported On: 2/11/2003 For: Version 3.21 Build 1 |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } DataPath: string; end; var Form1: TForm1; implementation {$R *.dfm} uses mmSystem, DBISAMTb; const ROWS = 1000000; BATCH = 1000; KEY = 500000; procedure TForm1.FormCreate(Sender: TObject); begin DataPath := ExtractFilePath(Application.ExeName); DBISAMTb.Session.PrivateDir := DataPath; end; procedure TForm1.Button1Click(Sender: TObject); var Q: TDBISAMQuery; begin Q := TDBISAMQuery.Create(nil); try with Q do begin DatabaseName := DataPath; SQL.Clear; SQL.Add('drop table if exists Test;'); SQL.Add( 'create table Test (' + 'Field1 char(10), ' + 'Field2 char(25), ' + 'primary key (Field1));'); SQL.Add('create index ix_Field2 on Test (Field2);'); ExecSQL; end; finally Q.Free; end; end; procedure TForm1.Button2Click(Sender: TObject); var DB: TDBISAMDatabase; Q: TDBISAMQuery; Start, Stop: Cardinal; Recs, i: Integer; begin DB := TDBISAMDatabase.Create(nil); try with DB do begin DatabaseName := 'TmpDB'; Directory := DataPath; end; Q := TDBISAMQuery.Create(nil); try with Q do begin DatabaseName := DB.DatabaseName; SQL.Text := 'insert into Test values(:Field1, :Field2);'; Caption := 'Inserting records...'; Start := TimeGetTime; Prepare; DB.StartTransaction; try for i := 1 to ROWS do begin Params[0].AsInteger := i; Params[1].AsString := Format( 'Field 2 - row # %s', [Params[0].AsString]); ExecSQL; Recs := i; if (i mod BATCH = 0) then begin DB.Commit; DB.StartTransaction; end; end; DB.Commit; except DB.Rollback; raise; end; Stop := TimeGetTime; Caption := Format('%d records inserted in %s secs', [Recs, FormatFloat('#0.000', (Stop-Start)/1000)]); end; finally Q.Free; end; finally DB.Free; end; end; procedure TForm1.Button3Click(Sender: TObject); var Q: TDBISAMQuery; Start, Stop: Cardinal; begin Q := TDBISAMQuery.Create(nil); try with Q do begin DatabaseName := DataPath; SQL.Text := Format( 'select * from Test where Field1 = ''%d''', [KEY]); Start := TimeGetTime; Active := True; Stop := TimeGetTime; Caption := Format('Select 1: %d records fetched in %s secs', [RecordCount, FormatFloat('#0.000', (Stop-Start)/1000)]); end; finally Q.Free; end; end; procedure TForm1.Button4Click(Sender: TObject); var Q: TDBISAMQuery; Start, Stop: Cardinal; begin Q := TDBISAMQuery.Create(nil); try with Q do begin DatabaseName := DataPath; SQL.Text := Format( 'select * from Test where Field1 like ''%%%d%%''', [KEY]); Start := TimeGetTime; Active := True; Stop := TimeGetTime; Caption := Format('Select 2: %d records fetched in %s secs', [RecordCount, FormatFloat('#0.000', (Stop-Start)/1000)]); end; finally Q.Free; end; end; end.
This web page was last updated on Wednesday, March 20, 2024 at 07:22 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |