1 program concurrencyds;
2 
3 {$Mode ObjFpc}
4 {$H+}
5 {$define DEBUGHEAP}
6 
7 uses
8 {$ifdef DEBUGHEAP}
9   Heaptrc,
10 {$endif}
11 {$ifdef Linux}
12   cmem,
13 {$endif}
14   sysutils,sqlite3ds, inifiles;
15 
16 const
17   SQLITEDS_TESTS_INI_FILE = 'sqlitedstests.ini';
18   DEFAULT_TABLENAME = 'tabletest';
19   DEFAULT_FILENAME = 'test.db';
20 
21   FieldNames: array [0..10] of String =
22   (
23   'Integer',
24   'String',
25   'Boolean',
26   'Float',
27   'Word',
28   'Date',
29   'DateTime',
30   'Time',
31   'LargeInt',
32   'AutoInc',
33   'Currency'
34   );
35 
36 var
37   dsArray: array [0..10] of TSqlite3Dataset;
38   ini:TIniFile;
39   i: Integer;
40 
41 begin
42   {$ifdef DEBUGHEAP}
43   SetHeapTraceOutput(ExtractFileName(ParamStr(0))+'.heap.log');
44   {$endif}
45   ini:=TIniFile.Create(SQLITEDS_TESTS_INI_FILE);
46   for i:= 0 to 10 do
47   begin
48     dsArray[i] := TSqlite3Dataset.Create(nil);
49     with dsArray[i] do
50     begin
51       FileName:=ini.ReadString('testinfo','filename',DEFAULT_FILENAME);
52       TableName:=ini.ReadString('testinfo','tablename',DEFAULT_TABLENAME);
53       //Each dataset will retrieve only one field of the same table
54       Sql:='Select '+FieldNames[i]+ ' from '+ TableName;
55       Open;
56       WriteLn('Value of Field ',FieldNames[i],' : ',FieldByName(FieldNames[i]).AsString);
57     end;
58   end;
59   ini.Destroy;
60   for i:= 0 to 10 do
61     dsArray[i].Destroy;
62 end.
63