ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/testsuite/Test6.pas
(Generate patch)

Comparing ibx/trunk/fbintf/testsuite/Test6.pas (file contents):
Revision 68 by tony, Tue Oct 17 10:07:58 2017 UTC vs.
Revision 315 by tony, Thu Feb 25 11:56:36 2021 UTC

# Line 1 | Line 1
1 + (*
2 + *  Firebird Interface (fbintf) Test suite. This program is used to
3 + *  test the Firebird Pascal Interface and provide a semi-automated
4 + *  pass/fail check for each test.
5 + *
6 + *  The contents of this file are subject to the Initial Developer's
7 + *  Public License Version 1.0 (the "License"); you may not use this
8 + *  file except in compliance with the License. You may obtain a copy
9 + *  of the License here:
10 + *
11 + *    http://www.firebirdsql.org/index.php?op=doc&id=idpl
12 + *
13 + *  Software distributed under the License is distributed on an "AS
14 + *  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15 + *  implied. See the License for the specific language governing rights
16 + *  and limitations under the License.
17 + *
18 + *  The Initial Developer of the Original Code is Tony Whyman.
19 + *
20 + *  The Original Code is (C) 2016 Tony Whyman, MWA Software
21 + *  (http://www.mwasoftware.co.uk).
22 + *
23 + *  All Rights Reserved.
24 + *
25 + *  Contributor(s): ______________________________________.
26 + *
27 + *)
28 +
29   unit Test6;
30   {$IFDEF MSWINDOWS}
31   {$DEFINE WINDOWS}
# Line 11 | Line 39 | unit Test6;
39   {Test 6: Blob Handling}
40  
41   {
42 <  1. Create an empty database and populate with a single table.
42 >  1. Create an empty database and populate with a single table and stored procedure
43 >     returning a blob.
44  
45    2. Show the character sets available (List RDB$CHARACTER_SETS)
46  
# Line 31 | Line 60 | unit Test6;
60  
61    10. Select all from new table.
62  
63 <  11. Drop Database and repeat above but with no default connection character set.
63 >  11. Execute Stored proc and display results
64 >
65 >  12. Drop Database and repeat above but with WIN1252 and  no default connection character set.
66   }
67  
68   interface
69  
70   uses
71 <  Classes, SysUtils, TestManager, IB;
71 >  Classes, SysUtils, TestApplication, FBTestApp, IB;
72  
73   type
74  
75    { TTest6 }
76  
77 <  TTest6 = class(TTestBase)
77 >  TTest6 = class(TFBTestBase)
78    private
79      procedure UpdateDatabase(Attachment: IAttachment);
80 +    procedure ExecProc(Attachment: IAttachment);
81    public
82      function TestTitle: AnsiString; override;
83      procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
# Line 64 | Line 96 | const
96      'Primary Key(RowID)'+
97      ')';
98  
99 +  sqlCreateProc =
100 +    'Create Procedure TestProc (RowID Integer) '+
101 +    'Returns (BlobData Blob sub_type 1 Character Set UTF8) '+
102 +    'As ' +
103 +    'Begin ' +
104 +    ' Select BlobData From TestData Where RowID = :RowID Into :BlobData; '+
105 +    'End';
106 +
107 +
108    sqlGetCharSets = 'Select RDB$CHARACTER_SET_NAME,RDB$CHARACTER_SET_ID from RDB$CHARACTER_SETS order by 2';
109  
110    sqlInsert = 'Insert into TestData(RowID,Title,FixedPoint,FloatingPoint) Values(:RowID,:Title,:FP, :DP)';
111  
112    sqlUpdate = 'Update TestData Set BlobData = ? Where RowID = ?';
113  
114 +  sqlExecProc = 'Execute Procedure TestProc ?';
115 +
116  
117   { TTest6 }
118  
# Line 78 | Line 121 | var Transaction: ITransaction;
121      Statement,
122      Statement2: IStatement;
123      ResultSet: IResultSet;
81    i: integer;
124   begin
125    Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taCommit);
126  
# Line 133 | Line 175 | begin
175    end;
176   end;
177  
178 + procedure TTest6.ExecProc(Attachment: IAttachment);
179 + var Transaction: ITransaction;
180 +    Statement: IStatement;
181 +    Results: IResults;
182 + begin
183 +  writeln(OutFile,'Testing Blob as stored proc parameter');
184 +  Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taCommit);
185 +
186 +  Statement := Attachment.Prepare(Transaction,sqlExecProc);
187 +  PrintMetaData(Statement.GetMetaData);
188 +  Statement.SQLParams[0].AsInteger := 1;
189 +  Results := Statement.Execute;
190 +  ReportResult(Results);
191 + end;
192 +
193   function TTest6.TestTitle: AnsiString;
194   begin
195    Result := 'Test 6: Blob Handling';
# Line 149 | Line 206 | begin
206    DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
207    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
208    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
209 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
210 +  UpdateDatabase(Attachment);
211 +  ExecProc(Attachment);
212 +
213 +  Attachment.DropDatabase;
214 +
215 +  {Repeat with WIN1252}
216 +  DPB := FirebirdAPI.AllocateDPB;
217 +  DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName);
218 +  DPB.Add(isc_dpb_password).setAsString(Owner.GetPassword);
219 +  DPB.Add(isc_dpb_lc_ctype).setAsString('WIN1252');
220 +  DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
221 +  Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
222 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
223 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
224    UpdateDatabase(Attachment);
225 +  ExecProc(Attachment);
226  
227    Attachment.DropDatabase;
228  
# Line 160 | Line 233 | begin
233    DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
234    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
235    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
236 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
237    UpdateDatabase(Attachment);
238 +  ExecProc(Attachment);
239  
240    Attachment.DropDatabase;
241   end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines