1 |
|
unit Test3; |
2 |
+ |
{$IFDEF MSWINDOWS} |
3 |
+ |
{$DEFINE WINDOWS} |
4 |
+ |
{$ENDIF} |
5 |
|
|
6 |
< |
{$mode objfpc}{$H+} |
6 |
> |
{$IFDEF FPC} |
7 |
> |
{$mode delphi} |
8 |
|
{$codepage utf8} |
9 |
+ |
{$ENDIF} |
10 |
|
|
11 |
|
{ Test 3: ad hoc queries} |
12 |
|
|
39 |
|
private |
40 |
|
procedure DoQuery(Attachment: IAttachment); |
41 |
|
public |
42 |
< |
function TestTitle: string; override; |
43 |
< |
procedure RunTest(CharSet: string; SQLDialect: integer); override; |
42 |
> |
function TestTitle: AnsiString; override; |
43 |
> |
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; |
44 |
|
end; |
45 |
|
|
46 |
|
|
53 |
|
ResultSet: IResultSet; |
54 |
|
Statement: IStatement; |
55 |
|
TPB: ITPB; |
56 |
+ |
us: UnicodeString; |
57 |
|
begin |
58 |
|
writeln(OutFile,'Employee Count = ',Attachment.OpenCursorAtStart('Select count(*) from EMPLOYEE')[0].AsInteger); |
59 |
|
|
75 |
|
ResultSet := Attachment.OpenCursorAtStart('Select count(*) from EMPLOYEE'); |
76 |
|
writeln(OutFile,'Employee Count = ',ResultSet[0].AsInteger); |
77 |
|
|
78 |
+ |
{$IFNDEF FPC} |
79 |
+ |
Transaction.Rollback; {Delphi does not dispose of interfaces until the end of the function |
80 |
+ |
so we need to explicitly rollback here. FPC will dispose of the |
81 |
+ |
interface as soon as it is overwritten - hence this is not needed.} |
82 |
+ |
{$ENDIF} |
83 |
|
Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taRollback); |
84 |
|
Statement := Attachment.PrepareWithNamedParameters(Transaction,'Execute Procedure DELETE_EMPLOYEE :EMP_NO',3); |
85 |
|
Statement.GetSQLParams.ByName('EMP_NO').AsInteger := 8; |
102 |
|
Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit), |
103 |
|
'Select count(*) As Counter from EMPLOYEE Where EMP_NO < ?',3,[8])[0].AsInteger); |
104 |
|
|
105 |
+ |
writeln(OutFile,'"Johnson" Employee Count = ',Attachment.OpenCursorAtStart( |
106 |
+ |
Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit), |
107 |
+ |
'Select count(*) As Counter from EMPLOYEE Where LAST_NAME = ?',3,['Johnson'])[0].AsInteger); |
108 |
+ |
|
109 |
+ |
us := UTF8Decode('Yanowski'); {Test a UnicodeString as a parameter} |
110 |
+ |
|
111 |
+ |
writeln(OutFile,'"Yanowski" Employee Count = ',Attachment.OpenCursorAtStart( |
112 |
+ |
Attachment.StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit), |
113 |
+ |
'Select count(*) As Counter from EMPLOYEE Where LAST_NAME = ?',3,[us])[0].AsInteger); |
114 |
+ |
|
115 |
|
end; |
116 |
|
|
117 |
< |
function TTest3.TestTitle: string; |
117 |
> |
function TTest3.TestTitle: AnsiString; |
118 |
|
begin |
119 |
|
Result := 'Test 3: ad hoc queries'; |
120 |
|
end; |
121 |
|
|
122 |
< |
procedure TTest3.RunTest(CharSet: string; SQLDialect: integer); |
122 |
> |
procedure TTest3.RunTest(CharSet: AnsiString; SQLDialect: integer); |
123 |
|
var Attachment: IAttachment; |
124 |
|
DPB: IDPB; |
125 |
|
begin |