63 |
|
TTest2 = class(TFBTestBase) |
64 |
|
private |
65 |
|
procedure DoQuery(Attachment: IAttachment); |
66 |
+ |
procedure DoScrollableQuery(Attachment: IAttachment); |
67 |
|
public |
68 |
|
function TestTitle: AnsiString; override; |
69 |
|
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; |
97 |
|
ReportResults(Statement); |
98 |
|
writeln(OutFile,'With param names'); |
99 |
|
Statement := Attachment.PrepareWithNamedParameters(Transaction, |
100 |
< |
'Select * from EMPLOYEE Where EMP_NO = :EMP_NO',3); |
100 |
> |
'Select * from EMPLOYEE Where EMP_NO = :EMP_NO',3,false,false,'Test Cursor'); |
101 |
|
Statement.SetRetainInterfaces(true); |
102 |
|
try |
103 |
|
writeln(OutFile,Statement.GetSQLText); |
104 |
|
ParamInfo(Statement.SQLParams); |
105 |
|
Statement.GetSQLParams.ByName('EMP_NO').AsInteger := 8; |
106 |
< |
ReportResults(Statement); |
106 |
> |
ReportResults(Statement,true); |
107 |
|
finally |
108 |
|
Statement.SetRetainInterfaces(false); |
109 |
|
end; |
110 |
|
end; |
111 |
|
|
112 |
+ |
procedure TTest2.DoScrollableQuery(Attachment: IAttachment); |
113 |
+ |
var Transaction: ITransaction; |
114 |
+ |
Statement: IStatement; |
115 |
+ |
Results: IResultSet; |
116 |
+ |
begin |
117 |
+ |
writeln(Outfile,'Scollable Cursors'); |
118 |
+ |
WriteAttachmentInfo(Attachment); |
119 |
+ |
Transaction := Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit); |
120 |
+ |
Statement := Attachment.Prepare(Transaction,'Select * from EMPLOYEE order by EMP_NO',3); |
121 |
+ |
Results := Statement.OpenCursor(true); |
122 |
+ |
writeln(Outfile,'Do Fetch Next:'); |
123 |
+ |
if Results.FetchNext then |
124 |
+ |
ReportResult(Results); |
125 |
+ |
writeln(Outfile,'Do Fetch Last:'); |
126 |
+ |
if Results.FetchLast then |
127 |
+ |
ReportResult(Results); |
128 |
+ |
writeln(Outfile,'Do Fetch Prior:'); |
129 |
+ |
if Results.FetchPrior then |
130 |
+ |
ReportResult(Results); |
131 |
+ |
writeln(Outfile,'Do Fetch First:'); |
132 |
+ |
if Results.FetchFirst then |
133 |
+ |
ReportResult(Results); |
134 |
+ |
writeln(Outfile,'Do Fetch Abs 8 :'); |
135 |
+ |
if Results.FetchAbsolute(8) then |
136 |
+ |
ReportResult(Results); |
137 |
+ |
writeln(Outfile,'Do Fetch Relative -2 :'); |
138 |
+ |
if Results.FetchRelative(-2) then |
139 |
+ |
ReportResult(Results); |
140 |
+ |
writeln(Outfile,'Do Fetch beyond EOF :'); |
141 |
+ |
if Results.FetchAbsolute(150) then |
142 |
+ |
ReportResult(Results) |
143 |
+ |
else |
144 |
+ |
writeln(Outfile,'Fetch returned false'); |
145 |
+ |
end; |
146 |
+ |
|
147 |
|
function TTest2.TestTitle: AnsiString; |
148 |
|
begin |
149 |
|
Result := 'Test 2: Open the employee database and run a query'; |
158 |
|
DPB.Add(isc_dpb_password).setAsString(' '); |
159 |
|
DPB.Add(isc_dpb_lc_ctype).setAsString(CharSet); |
160 |
|
DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect); |
125 |
– |
DPB.Find(isc_dpb_password).setAsString(Owner.GetPassword); |
161 |
|
try |
162 |
|
Attachment := FirebirdAPI.OpenDatabase(Owner.GetEmployeeDatabaseName,DPB); |
163 |
|
except on e: Exception do |
164 |
|
writeln(OutFile,'Open Database fails ',E.Message); |
165 |
|
end; |
166 |
+ |
DPB.Find(isc_dpb_password).setAsString(Owner.GetPassword); |
167 |
|
writeln(OutFile,'Opening ',Owner.GetEmployeeDatabaseName); |
168 |
|
Attachment := FirebirdAPI.OpenDatabase(Owner.GetEmployeeDatabaseName,DPB); |
169 |
|
writeln(OutFile,'Database Open, SQL Dialect = ',Attachment.GetSQLDialect); |
170 |
|
DoQuery(Attachment); |
171 |
+ |
if Attachment.HasScollableCursors then |
172 |
+ |
try |
173 |
+ |
DoScrollableQuery(Attachment); |
174 |
+ |
except on e: Exception do |
175 |
+ |
writeln(OutFile,'Remote Scrollable cursors test fails ',E.Message); |
176 |
+ |
end; |
177 |
|
Attachment.Disconnect; |
178 |
|
writeln(OutFile,'Now open the employee database as a local database'); |
179 |
|
DPB := FirebirdAPI.AllocateDPB; |
188 |
|
writeln(OutFile,'Open Local Database fails ',E.Message); |
189 |
|
end; |
190 |
|
DoQuery(Attachment); |
191 |
+ |
if Attachment.HasScollableCursors then |
192 |
+ |
DoScrollableQuery(Attachment); |
193 |
|
Attachment.Disconnect; |
194 |
|
end; |
195 |
|
|