1 |
(*
|
2 |
* IBX Test suite. This program is used to test the IBX non-visual
|
3 |
* components and provides a semi-automated pass/fail check for each test.
|
4 |
*
|
5 |
* The contents of this file are subject to the Initial Developer's
|
6 |
* Public License Version 1.0 (the "License"); you may not use this
|
7 |
* file except in compliance with the License. You may obtain a copy
|
8 |
* of the License here:
|
9 |
*
|
10 |
* http://www.firebirdsql.org/index.php?op=doc&id=idpl
|
11 |
*
|
12 |
* Software distributed under the License is distributed on an "AS
|
13 |
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
14 |
* implied. See the License for the specific language governing rights
|
15 |
* and limitations under the License.
|
16 |
*
|
17 |
* The Initial Developer of the Original Code is Tony Whyman.
|
18 |
*
|
19 |
* The Original Code is (C) 2021 Tony Whyman, MWA Software
|
20 |
* (http://www.mwasoftware.co.uk).
|
21 |
*
|
22 |
* All Rights Reserved.
|
23 |
*
|
24 |
* Contributor(s): ______________________________________.
|
25 |
*
|
26 |
*)
|
27 |
unit Test17;
|
28 |
|
29 |
{$mode objfpc}{$H+}
|
30 |
|
31 |
{Test 17: TIBDataSet Tests}
|
32 |
|
33 |
{ Description
|
34 |
|
35 |
TIBDataset Insert/Update/Delete tests.
|
36 |
}
|
37 |
|
38 |
interface
|
39 |
|
40 |
uses
|
41 |
Classes, SysUtils, TestApplication, IBXTestBase, DB, IB, IBCustomDataSet;
|
42 |
|
43 |
const
|
44 |
aTestID = '17';
|
45 |
aTestTitle = 'TIBDataset Tests';
|
46 |
|
47 |
type
|
48 |
|
49 |
{ TTest1 }
|
50 |
|
51 |
{ TTest17 }
|
52 |
|
53 |
TTest17 = class(TIBXTestBase)
|
54 |
private
|
55 |
FIBDataSet1: TIBDataSet;
|
56 |
FIBDataSet2: TIBDataSet;
|
57 |
F2KeyDataset: TIBDataset;
|
58 |
procedure HandleDeleteReturning(Sender: TObject; QryResults: IResults);
|
59 |
procedure HandleBeforeOpen(DataSet: TDataSet);
|
60 |
procedure HandleAfterOpen(DataSet: TDataSet);
|
61 |
procedure HandleBeforeClose(DataSet: TDataSet);
|
62 |
procedure HandleAfterClose(DataSet: TDataSet);
|
63 |
procedure HandleBeforeInsert(DataSet: TDataSet);
|
64 |
procedure HandleAfterInsert(DataSet: TDataSet);
|
65 |
procedure HandleBeforeEdit(DataSet: TDataSet);
|
66 |
procedure HandleAfterEdit(DataSet: TDataSet);
|
67 |
procedure HandleBeforePost(DataSet: TDataSet);
|
68 |
procedure HandleAfterPost(DataSet: TDataSet);
|
69 |
procedure HandleBeforeCancel(DataSet: TDataSet);
|
70 |
procedure HandleAfterCancel(DataSet: TDataSet);
|
71 |
procedure HandleBeforeDelete(DataSet: TDataSet);
|
72 |
procedure HandleAfterDelete(DataSet: TDataSet);
|
73 |
procedure HandleBeforeScroll(DataSet: TDataSet);
|
74 |
procedure HandleAfterScroll(DataSet: TDataSet);
|
75 |
procedure HandleBeforeRefresh(DataSet: TDataSet);
|
76 |
procedure HandleAfterRefresh(DataSet: TDataSet);
|
77 |
procedure ValidatePostOK(Sender: TObject; var CancelPost: boolean);
|
78 |
procedure ValidatePostCancel(Sender: TObject; var CancelPost: boolean);
|
79 |
procedure HandlePostError(DataSet: TDataSet; E: EDatabaseError;
|
80 |
var DataAction: TDataAction);
|
81 |
protected
|
82 |
procedure CreateObjects(Application: TTestApplication); override;
|
83 |
function GetTestID: AnsiString; override;
|
84 |
function GetTestTitle: AnsiString; override;
|
85 |
procedure InitTest; override;
|
86 |
public
|
87 |
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
|
88 |
end;
|
89 |
|
90 |
|
91 |
implementation
|
92 |
|
93 |
{ TTest17 }
|
94 |
|
95 |
procedure TTest17.HandleDeleteReturning(Sender: TObject; QryResults: IResults);
|
96 |
begin
|
97 |
writeln(OutFile,'Delete Returning');
|
98 |
ReportResult(QryResults);
|
99 |
writeln(OutFile);
|
100 |
end;
|
101 |
|
102 |
procedure TTest17.HandleBeforeOpen(DataSet: TDataSet);
|
103 |
Begin
|
104 |
writeln(Outfile,'Dataset Event BeforeOpen: State = ',DataSet.State);
|
105 |
end;
|
106 |
procedure TTest17.HandleAfterOpen(DataSet: TDataSet);
|
107 |
Begin
|
108 |
writeln(Outfile,'Dataset Event AfterOpen: State = ',DataSet.State);
|
109 |
end;
|
110 |
procedure TTest17.HandleBeforeClose(DataSet: TDataSet);
|
111 |
Begin
|
112 |
writeln(Outfile,'Dataset Event BeforeClose: State = ',DataSet.State);
|
113 |
end;
|
114 |
procedure TTest17.HandleAfterClose(DataSet: TDataSet);
|
115 |
Begin
|
116 |
writeln(Outfile,'Dataset Event AfterClose: State = ',DataSet.State);
|
117 |
end;
|
118 |
procedure TTest17.HandleBeforeInsert(DataSet: TDataSet);
|
119 |
Begin
|
120 |
writeln(Outfile,'Dataset Event BeforeInsert: State = ',DataSet.State);
|
121 |
end;
|
122 |
procedure TTest17.HandleAfterInsert(DataSet: TDataSet);
|
123 |
Begin
|
124 |
writeln(Outfile,'Dataset Event AfterInsert: State = ',DataSet.State);
|
125 |
end;
|
126 |
procedure TTest17.HandleBeforeEdit(DataSet: TDataSet);
|
127 |
Begin
|
128 |
writeln(Outfile,'Dataset Event BeforeEdit: State = ',DataSet.State);
|
129 |
end;
|
130 |
procedure TTest17.HandleAfterEdit(DataSet: TDataSet);
|
131 |
Begin
|
132 |
writeln(Outfile,'Dataset Event AfterEdit: State = ',DataSet.State);
|
133 |
end;
|
134 |
procedure TTest17.HandleBeforePost(DataSet: TDataSet);
|
135 |
Begin
|
136 |
writeln(Outfile,'Dataset Event BeforePost: State = ',DataSet.State);
|
137 |
end;
|
138 |
procedure TTest17.HandleAfterPost(DataSet: TDataSet);
|
139 |
Begin
|
140 |
writeln(Outfile,'Dataset Event AfterPost: State = ',DataSet.State);
|
141 |
end;
|
142 |
procedure TTest17.HandleBeforeCancel(DataSet: TDataSet);
|
143 |
Begin
|
144 |
writeln(Outfile,'Dataset Event BeforeCancel: State = ',DataSet.State);
|
145 |
end;
|
146 |
procedure TTest17.HandleAfterCancel(DataSet: TDataSet);
|
147 |
Begin
|
148 |
writeln(Outfile,'Dataset Event AfterCancel: State = ',DataSet.State);
|
149 |
end;
|
150 |
procedure TTest17.HandleBeforeDelete(DataSet: TDataSet);
|
151 |
Begin
|
152 |
writeln(Outfile,'Dataset Event BeforeDelete: State = ',DataSet.State);
|
153 |
end;
|
154 |
procedure TTest17.HandleAfterDelete(DataSet: TDataSet);
|
155 |
Begin
|
156 |
writeln(Outfile,'Dataset Event AfterDelete: State = ',DataSet.State);
|
157 |
end;
|
158 |
procedure TTest17.HandleBeforeScroll(DataSet: TDataSet);
|
159 |
Begin
|
160 |
writeln(Outfile,'Dataset Event BeforeScroll: State = ',DataSet.State);
|
161 |
end;
|
162 |
procedure TTest17.HandleAfterScroll(DataSet: TDataSet);
|
163 |
Begin
|
164 |
writeln(Outfile,'Dataset Event AfterScroll: State = ',DataSet.State);
|
165 |
end;
|
166 |
procedure TTest17.HandleBeforeRefresh(DataSet: TDataSet);
|
167 |
Begin
|
168 |
writeln(Outfile,'Dataset Event BeforeRefresh: State = ',DataSet.State);
|
169 |
end;
|
170 |
procedure TTest17.HandleAfterRefresh(DataSet: TDataSet);
|
171 |
Begin
|
172 |
writeln(Outfile,'Dataset Event AfterRefresh: State = ',DataSet.State);
|
173 |
end;
|
174 |
|
175 |
procedure TTest17.ValidatePostOK(Sender: TObject; var CancelPost: boolean);
|
176 |
begin
|
177 |
writeln(Outfile,'Validate Post OK called');
|
178 |
CancelPost := false;
|
179 |
end;
|
180 |
|
181 |
procedure TTest17.ValidatePostCancel(Sender: TObject; var CancelPost: boolean);
|
182 |
begin
|
183 |
writeln(Outfile,'Validate Post Cancel called');
|
184 |
CancelPost := true;
|
185 |
end;
|
186 |
|
187 |
procedure TTest17.HandlePostError(DataSet: TDataSet; E: EDatabaseError;
|
188 |
var DataAction: TDataAction);
|
189 |
begin
|
190 |
writeln(Outfile,'Post Error Called: ',E.Message);
|
191 |
DataAction := daFail;
|
192 |
end;
|
193 |
|
194 |
procedure TTest17.CreateObjects(Application: TTestApplication);
|
195 |
begin
|
196 |
inherited CreateObjects(Application);
|
197 |
FIBDataSet1 := TIBDataSet.Create(Application);
|
198 |
with FIBDataSet1 do
|
199 |
begin
|
200 |
Database := IBDatabase;
|
201 |
Transaction := IBTransaction;
|
202 |
Unidirectional := false;
|
203 |
SelectSQL.Add('Select * From IBDataSetTest');
|
204 |
InsertSQL.Add('Insert into IBDataSetTest(KeyField,PlainText) Values (:KeyField,:PlainText)');
|
205 |
ModifySQL.Add('Update IBDataSetTest Set KeyField = :KeyField, PlainText = :PlainText Where KeyField = :Old_KeyField');
|
206 |
DeleteSQL.Add('Delete from IBDataSetTest Where KeyField = :old_KeyField');
|
207 |
RefreshSQL.Add('Select * from IBDataSetTest Where KeyField = :KeyField');
|
208 |
GeneratorField.Field := 'KeyField';
|
209 |
GeneratorField.Generator := 'AGENERATOR';
|
210 |
GeneratorField.Increment := 1;
|
211 |
OnPostError := @HandlePostError;
|
212 |
end;
|
213 |
FIBDataSet2 := TIBDataSet.Create(Application);
|
214 |
with FIBDataSet2 do
|
215 |
begin
|
216 |
Database := IBDatabase;
|
217 |
Transaction := IBTransaction;
|
218 |
Unidirectional := false;
|
219 |
SelectSQL.Add('Select * From IBDataSetTest');
|
220 |
InsertSQL.Add('Insert into IBDataSetTest(KeyField,PlainText) Values (Gen_ID(AGenerator,1),:PlainText) Returning KeyField, TextAndKey');
|
221 |
ModifySQL.Add('Update IBDataSetTest Set KeyField = :KeyField, PlainText = :PlainText Where KeyField = :Old_KeyField Returning TextAndKey,ServerSideText');
|
222 |
DeleteSQL.Add('Delete from IBDataSetTest Where KeyField = :old_KeyField Returning KeyField');
|
223 |
RefreshSQL.Add('Select * from IBDataSetTest Where KeyField = :KeyField');
|
224 |
OnDeleteReturning := @HandleDeleteReturning;
|
225 |
BeforeOpen := @HandleBeforeOpen;
|
226 |
AfterOpen := @HandleAfterOpen;
|
227 |
BeforeClose := @HandleBeforeClose;
|
228 |
AfterClose := @HandleAfterClose;
|
229 |
BeforeInsert := @HandleBeforeInsert;
|
230 |
AfterInsert := @HandleAfterInsert;
|
231 |
BeforeEdit := @HandleBeforeEdit;
|
232 |
AfterEdit := @HandleAfterEdit;
|
233 |
BeforePost := @HandleBeforePost;
|
234 |
AfterPost := @HandleAfterPost;
|
235 |
BeforeCancel := @HandleBeforeCancel;
|
236 |
AfterCancel := @HandleAfterCancel;
|
237 |
BeforeDelete := @HandleBeforeDelete;
|
238 |
AfterDelete := @HandleAfterDelete;
|
239 |
BeforeScroll := @HandleBeforeScroll;
|
240 |
AfterScroll := @HandleAfterScroll;
|
241 |
BeforeRefresh := @HandleBeforeRefresh;
|
242 |
AfterRefresh := @HandleAfterRefresh;
|
243 |
end;
|
244 |
F2KeyDataset := TIBDataSet.Create(Application);
|
245 |
with F2KeyDataset do
|
246 |
begin
|
247 |
Database := IBDatabase;
|
248 |
Transaction := IBTransaction;
|
249 |
SelectSQL.Text := 'Select Key1, Key2 From IBXTest2';
|
250 |
InsertSQL.Text := 'Insert into IBXTest2(Key1,Key2) Values(:Key1,:Key2)';
|
251 |
RefreshSQL.Text := 'Select Key1, Key2 From IBXTest2 where Key1 = :Key1 and Key2 = :Key2';
|
252 |
end;
|
253 |
end;
|
254 |
|
255 |
function TTest17.GetTestID: AnsiString;
|
256 |
begin
|
257 |
Result := aTestID;
|
258 |
end;
|
259 |
|
260 |
function TTest17.GetTestTitle: AnsiString;
|
261 |
begin
|
262 |
Result := aTestTitle;
|
263 |
end;
|
264 |
|
265 |
procedure TTest17.InitTest;
|
266 |
begin
|
267 |
IBDatabase.DatabaseName := Owner.GetNewDatabaseName;
|
268 |
IBDatabase.CreateIfNotExists := true;
|
269 |
ReadWriteTransaction;
|
270 |
end;
|
271 |
|
272 |
procedure TTest17.RunTest(CharSet: AnsiString; SQLDialect: integer);
|
273 |
var lastKey: integer;
|
274 |
i: integer;
|
275 |
B: TBookmark;
|
276 |
begin
|
277 |
IBDatabase.CreateDatabase;
|
278 |
try
|
279 |
IBTransaction.Active := true;
|
280 |
with FIBDataSet1 do
|
281 |
begin
|
282 |
Active := true;
|
283 |
writeln(OutFile,'FIBDataSet1: Simple Append');
|
284 |
Append;
|
285 |
// writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);
|
286 |
FieldByName('PlainText').AsString := 'This is a test';
|
287 |
Post;
|
288 |
PrintDataSetRow(FIBDataSet1);
|
289 |
Refresh;
|
290 |
writeln(OutFile,'After Refresh');
|
291 |
PrintDataSetRow(FIBDataSet1);
|
292 |
writeln(OutFile,'Append and Update');
|
293 |
Append;
|
294 |
FieldByName('PlainText').AsString := 'This is another test';
|
295 |
Post;
|
296 |
PrintDataSetRow(FIBDataSet1);
|
297 |
Edit;
|
298 |
FieldByName('PlainText').AsString := 'This is the update test';
|
299 |
Post;
|
300 |
PrintDataSetRow(FIBDataSet1);
|
301 |
writeln(Outfile,'Show whole Dataset');
|
302 |
PrintDataSet(FIBDataSet1);
|
303 |
writeln(OutFile,'Now delete the first row');
|
304 |
First;
|
305 |
Delete;
|
306 |
PrintDataSet(FIBDataSet1);
|
307 |
writeln(Outfile,'On Post KeyField Assignment');
|
308 |
FIBDataSet1.GeneratorField.ApplyOnEvent := gaeOnPostRecord;
|
309 |
Append;
|
310 |
FieldByName('PlainText').AsString := 'On Post KeyField test';
|
311 |
PrintDataSetRow(FIBDataSet1);
|
312 |
Post;
|
313 |
writeln(Outfile,'Row data after post');
|
314 |
PrintDataSetRow(FIBDataSet1);
|
315 |
FIBDataSet1.GeneratorField.ApplyOnEvent := gaeOnNewRecord; {restore}
|
316 |
|
317 |
writeln(Outfile,'Catch a Post Error - duplicate key');
|
318 |
lastkey := FieldByName('KeyField').AsInteger;
|
319 |
Append;
|
320 |
FieldByName('KeyField').AsInteger := lastkey;
|
321 |
FieldByName('PlainText').AsString := 'On Post Error test';
|
322 |
try
|
323 |
Post;
|
324 |
except on E: Exception do
|
325 |
writeln(Outfile,'Exception handled: ',E.Message);
|
326 |
end;
|
327 |
|
328 |
IBTransaction.Rollback;
|
329 |
IBTransaction.Active := true;
|
330 |
DataSetCloseAction := dcSaveChanges;
|
331 |
Active := true;
|
332 |
writeln(OutFile,'FIBDataSet1: Simple Append with automatic posting on close');
|
333 |
Append;
|
334 |
FieldByName('PlainText').AsString := 'This is a test';
|
335 |
Active := false;
|
336 |
Active := true;
|
337 |
PrintDataSet(FIBDataSet1);
|
338 |
|
339 |
IBTransaction.Rollback;
|
340 |
IBTransaction.Active := true;
|
341 |
DataSetCloseAction := dcDiscardChanges;
|
342 |
Active := true;
|
343 |
writeln(OutFile,'FIBDataSet1: Simple Append with discard on close');
|
344 |
Append;
|
345 |
FieldByName('PlainText').AsString := 'This is a test';
|
346 |
Active := false;
|
347 |
Active := true;
|
348 |
PrintDataSet(FIBDataSet1);
|
349 |
|
350 |
IBTransaction.Rollback;
|
351 |
IBTransaction.Active := true;
|
352 |
writeln(Outfile);
|
353 |
writeln(Outfile,'Unidirectional editing');
|
354 |
Unidirectional := true;
|
355 |
Active := true;
|
356 |
writeln(OutFile,'FIBDataSet1: Simple Append - unidirectional');
|
357 |
Insert;
|
358 |
writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);
|
359 |
FieldByName('PlainText').AsString := 'This is a test - unidirectional';
|
360 |
PrintDataSetRow(FIBDataSet1);
|
361 |
Post;
|
362 |
writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);
|
363 |
PrintDataSetRow(FIBDataSet1);
|
364 |
Refresh;
|
365 |
writeln(OutFile,'After Refresh - unidirectional');
|
366 |
PrintDataSetRow(FIBDataSet1);
|
367 |
writeln(OutFile,' Record Count = ',FIBDataSet1.RecordCount);
|
368 |
writeln(OutFile,'Insert and Update');
|
369 |
Insert;
|
370 |
FieldByName('PlainText').AsString := 'This is another test - unidirectional';
|
371 |
Post;
|
372 |
PrintDataSetRow(FIBDataSet1);
|
373 |
Edit;
|
374 |
FieldByName('PlainText').AsString := 'This is the update test - unidirectional';
|
375 |
Post;
|
376 |
PrintDataSetRow(FIBDataSet1);
|
377 |
writeln(OutFile,'Now delete the first row - unidirectional with Record Count = ',FIBDataSet1.RecordCount);
|
378 |
Active := false;
|
379 |
Active := true;
|
380 |
Delete;
|
381 |
writeln(OutFile,'Show Current Row');
|
382 |
PrintDataSetRow(FIBDataSet1);
|
383 |
writeln(OutFile,' Record Count = ',FIBDataSet1.RecordCount);
|
384 |
writeln(Outfile,'Ensure dataset saved to database');
|
385 |
Active := false;
|
386 |
Active := true;
|
387 |
PrintDataSet(FIBDataSet1);
|
388 |
|
389 |
end;
|
390 |
writeln(Outfile,'==================================');
|
391 |
IBTransaction.Rollback;
|
392 |
IBTransaction.Active := true;
|
393 |
with FIBDataSet2 do
|
394 |
try
|
395 |
Active := true;
|
396 |
writeln(OutFile,'FIBDataSet2: Simple Append');
|
397 |
Append;
|
398 |
FieldByName('PlainText').AsString := 'This is a test';
|
399 |
Post;
|
400 |
PrintDataSetRow(FIBDataSet2);
|
401 |
Refresh;
|
402 |
writeln(OutFile,'After Refresh');
|
403 |
PrintDataSetRow(FIBDataSet2);
|
404 |
writeln(OutFile,'Append and Update');
|
405 |
Append;
|
406 |
FieldByName('PlainText').AsString := 'This is another test';
|
407 |
Post;
|
408 |
PrintDataSetRow(FIBDataSet2);
|
409 |
Edit;
|
410 |
FieldByName('PlainText').AsString := 'This is the update test';
|
411 |
Post;
|
412 |
PrintDataSetRow(FIBDataSet2);
|
413 |
writeln(OutFile,'Now delete the first row');
|
414 |
PrintDataSet(FIBDataSet2);
|
415 |
First;
|
416 |
Delete;
|
417 |
PrintDataSet(FIBDataSet2);
|
418 |
OnValidatePost := @ValidatePostOK;
|
419 |
writeln(Outfile,'Validate Post OK');
|
420 |
Append;
|
421 |
FieldByName('PlainText').AsString := 'This is a validated Post';
|
422 |
Post;
|
423 |
PrintDataSetRow(FIBDataSet2);
|
424 |
OnValidatePost := @ValidatePostCancel;
|
425 |
writeln(Outfile,'Validate Post Cancel');
|
426 |
Append;
|
427 |
FieldByName('PlainText').AsString := 'This is a validated Post which should have been cancelled';
|
428 |
Post;
|
429 |
PrintDataSetRow(FIBDataSet2);
|
430 |
OnValidatePost := nil;
|
431 |
writeln(OutFile,'FIBDataSet2: Simple Append with Forced Refresh');
|
432 |
ForcedRefresh := true;
|
433 |
Append;
|
434 |
FieldByName('PlainText').AsString := 'This is a test';
|
435 |
Post;
|
436 |
PrintDataSetRow(FIBDataSet2);
|
437 |
except on E: Exception do
|
438 |
writeln(Outfile,E.Message);
|
439 |
end;
|
440 |
IBTransaction.Rollback;
|
441 |
IBTransaction.Active := true;
|
442 |
with FIBDataSet1 do
|
443 |
try
|
444 |
Unidirectional := false;
|
445 |
Active := true;
|
446 |
writeln(outfile,'----------------------------------------------');
|
447 |
writeln(OutFile,'FIBDataSet1: Insert at start');
|
448 |
for i := 1 to 2 do
|
449 |
begin
|
450 |
Append;
|
451 |
FieldByName('PlainText').AsString := 'Row ' + IntToStr(i);
|
452 |
Post;
|
453 |
end;
|
454 |
First;
|
455 |
Insert;
|
456 |
FieldByName('PlainText').AsString := 'This is an insert test';
|
457 |
Post;
|
458 |
B := Bookmark;
|
459 |
PrintDataSet(FIBDataSet1);
|
460 |
writeln(outfile,'Delete inserted row');
|
461 |
Bookmark := B;
|
462 |
Delete;
|
463 |
PrintDataSet(FIBDataSet1);
|
464 |
writeln(outfile,'Repeat');
|
465 |
First;
|
466 |
Insert;
|
467 |
FieldByName('PlainText').AsString := 'This is an insert test #1';
|
468 |
Post;
|
469 |
B := Bookmark;
|
470 |
PrintDataSet(FIBDataSet1);
|
471 |
writeln(outfile,'Delete inserted row');
|
472 |
Bookmark := B;
|
473 |
Delete;
|
474 |
PrintDataSet(FIBDataSet1);
|
475 |
writeln(outfile,'Insert/Delete after first row');
|
476 |
Next;
|
477 |
Insert;
|
478 |
FieldByName('PlainText').AsString := 'This is an insert test #2';
|
479 |
Post;
|
480 |
B := Bookmark;
|
481 |
PrintDataSet(FIBDataSet1);
|
482 |
writeln(outfile,'Delete inserted row');
|
483 |
Bookmark := B;
|
484 |
Delete;
|
485 |
PrintDataSet(FIBDataSet1);
|
486 |
writeln(outfile,'Insert/Delete at last row');
|
487 |
Last;
|
488 |
Insert;
|
489 |
FieldByName('PlainText').AsString := 'This is an insert test #3';
|
490 |
Post;
|
491 |
B := Bookmark;
|
492 |
PrintDataSet(FIBDataSet1);
|
493 |
writeln(outfile,'Delete inserted row');
|
494 |
Bookmark := B;
|
495 |
Delete;
|
496 |
PrintDataSet(FIBDataSet1);
|
497 |
except on E: Exception do
|
498 |
writeln(Outfile,E.Message);
|
499 |
end;
|
500 |
|
501 |
writeln(outfile,'Refresh Dataset wit two primary keys');
|
502 |
with F2KeyDataset do
|
503 |
try
|
504 |
Transaction.Active := true;
|
505 |
Active := true;
|
506 |
Append;
|
507 |
FieldByName('Key1').AsInteger := 1;
|
508 |
FieldByName('Key2').AsInteger := 1;
|
509 |
Post;
|
510 |
Append;
|
511 |
FieldByName('Key1').AsInteger := 1;
|
512 |
FieldByName('Key2').AsInteger := 2;
|
513 |
Post;
|
514 |
Refresh;
|
515 |
PrintDataset(F2KeyDataset);
|
516 |
except on E: Exception do
|
517 |
writeln(Outfile,E.Message);
|
518 |
end;
|
519 |
|
520 |
finally
|
521 |
IBDatabase.DropDatabase;
|
522 |
end;
|
523 |
end;
|
524 |
|
525 |
initialization
|
526 |
RegisterTest(TTest17);
|
527 |
|
528 |
end.
|
529 |
|