33 |
|
{ This is a simple use of IBX to access the employee database in console mode. |
34 |
|
The program opens the database, runs a query and writes the result to stdout. |
35 |
|
|
36 |
+ |
If Scrollable cursors are supported then these calls are excercised. |
37 |
+ |
|
38 |
|
} |
39 |
|
|
40 |
|
interface |
53 |
|
TTest07 = class(TIBXTestBase) |
54 |
|
private |
55 |
|
FIBSQL: TIBSQL; |
56 |
+ |
procedure DoScrollableQuery; |
57 |
|
protected |
58 |
|
procedure CreateObjects(Application: TTestApplication); override; |
59 |
|
function GetTestID: AnsiString; override; |
86 |
|
|
87 |
|
{ TTest07 } |
88 |
|
|
89 |
+ |
procedure TTest07.DoScrollableQuery; |
90 |
+ |
begin |
91 |
+ |
with FIBSQL do |
92 |
+ |
begin |
93 |
+ |
Scrollable := true; |
94 |
+ |
GoToFirstRecordOnExecute := false; |
95 |
+ |
writeln(OutFile); |
96 |
+ |
writeln(Outfile,'Scollable Cursors'); |
97 |
+ |
SQL.Text := 'Select * from EMPLOYEE order by EMP_NO'; |
98 |
+ |
Transaction.Active := true; |
99 |
+ |
Prepare; |
100 |
+ |
ExecQuery; |
101 |
+ |
writeln(Outfile,'Do Fetch Next:'); |
102 |
+ |
if FetchNext then |
103 |
+ |
ReportResult(Current); |
104 |
+ |
writeln(Outfile,'Do Fetch Last:'); |
105 |
+ |
if FetchLast then |
106 |
+ |
ReportResult(Current); |
107 |
+ |
writeln(Outfile,'Do Fetch Prior:'); |
108 |
+ |
if FetchPrior then |
109 |
+ |
ReportResult(Current); |
110 |
+ |
writeln(Outfile,'Do Fetch First:'); |
111 |
+ |
if FetchFirst then |
112 |
+ |
ReportResult(Current); |
113 |
+ |
writeln(Outfile,'Do Fetch Abs 8 :'); |
114 |
+ |
if FetchAbsolute(8) then |
115 |
+ |
ReportResult(Current); |
116 |
+ |
writeln(Outfile,'Do Fetch Relative -2 :'); |
117 |
+ |
if FetchRelative(-2) then |
118 |
+ |
ReportResult(Current); |
119 |
+ |
writeln(Outfile,'Do Fetch beyond EOF :'); |
120 |
+ |
if FetchAbsolute(150) then |
121 |
+ |
ReportResult(Current) |
122 |
+ |
else |
123 |
+ |
writeln(Outfile,'Fetch returned false'); |
124 |
+ |
Close; |
125 |
+ |
end; |
126 |
+ |
end; |
127 |
+ |
|
128 |
|
procedure TTest07.CreateObjects(Application: TTestApplication); |
129 |
|
begin |
130 |
|
inherited CreateObjects(Application); |
236 |
|
writeln(OutFile,'Terminated with Exception:',E.Message); |
237 |
|
end; |
238 |
|
Transaction.Rollback; |
239 |
+ |
if FIBSQL.HasScollableCursors then |
240 |
+ |
DoScrollableQuery; |
241 |
|
end; |
242 |
+ |
IBDatabase.Connected := false; |
243 |
+ |
IBDatabase.DatabaseName := ExtractDBName(Owner.GetEmployeeDatabaseName); {open as local database} |
244 |
+ |
IBDatabase.Connected := true; |
245 |
+ |
if FIBSQL.HasScollableCursors then |
246 |
+ |
DoScrollableQuery; |
247 |
|
end; |
248 |
|
|
249 |
|
initialization |