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 |
+ |
Transaction := Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit); |
119 |
+ |
Statement := Attachment.Prepare(Transaction,'Select * from EMPLOYEE order by EMP_NO',3); |
120 |
+ |
Results := Statement.OpenCursor(true); |
121 |
+ |
writeln(Outfile,'Do Fetch Next:'); |
122 |
+ |
if Results.FetchNext then |
123 |
+ |
ReportResult(Results); |
124 |
+ |
writeln(Outfile,'Do Fetch Last:'); |
125 |
+ |
if Results.FetchLast then |
126 |
+ |
ReportResult(Results); |
127 |
+ |
writeln(Outfile,'Do Fetch Prior:'); |
128 |
+ |
if Results.FetchPrior then |
129 |
+ |
ReportResult(Results); |
130 |
+ |
writeln(Outfile,'Do Fetch First:'); |
131 |
+ |
if Results.FetchFirst then |
132 |
+ |
ReportResult(Results); |
133 |
+ |
writeln(Outfile,'Do Fetch Abs 8 :'); |
134 |
+ |
if Results.FetchAbsolute(8) then |
135 |
+ |
ReportResult(Results); |
136 |
+ |
writeln(Outfile,'Do Fetch Relative -2 :'); |
137 |
+ |
if Results.FetchRelative(-2) then |
138 |
+ |
ReportResult(Results); |
139 |
+ |
writeln(Outfile,'Do Fetch beyond EOF :'); |
140 |
+ |
if Results.FetchAbsolute(150) then |
141 |
+ |
ReportResult(Results) |
142 |
+ |
else |
143 |
+ |
writeln(Outfile,'Fetch returned false'); |
144 |
+ |
end; |
145 |
+ |
|
146 |
|
function TTest2.TestTitle: AnsiString; |
147 |
|
begin |
148 |
|
Result := 'Test 2: Open the employee database and run a query'; |
181 |
|
writeln(OutFile,'Open Local Database fails ',E.Message); |
182 |
|
end; |
183 |
|
DoQuery(Attachment); |
184 |
+ |
if FirebirdAPI.HasScollableCursors then |
185 |
+ |
DoScrollableQuery(Attachment); |
186 |
|
Attachment.Disconnect; |
187 |
|
end; |
188 |
|
|