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 111 by tony, Thu Jan 18 14:37:53 2018 UTC

# Line 11 | Line 11 | unit Test6;
11   {Test 6: Blob Handling}
12  
13   {
14 <  1. Create an empty database and populate with a single table.
14 >  1. Create an empty database and populate with a single table and stored procedure
15 >     returning a blob.
16  
17    2. Show the character sets available (List RDB$CHARACTER_SETS)
18  
# Line 31 | Line 32 | unit Test6;
32  
33    10. Select all from new table.
34  
35 <  11. Drop Database and repeat above but with no default connection character set.
35 >  11. Execute Stored proc and display results
36 >
37 >  12. Drop Database and repeat above but with WIN1252 and  no default connection character set.
38   }
39  
40   interface
# Line 46 | Line 49 | type
49    TTest6 = class(TTestBase)
50    private
51      procedure UpdateDatabase(Attachment: IAttachment);
52 +    procedure ExecProc(Attachment: IAttachment);
53    public
54      function TestTitle: AnsiString; override;
55      procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
# Line 64 | Line 68 | const
68      'Primary Key(RowID)'+
69      ')';
70  
71 +  sqlCreateProc =
72 +    'Create Procedure TestProc (RowID Integer) '+
73 +    'Returns (BlobData Blob sub_type 1 Character Set UTF8) '+
74 +    'As ' +
75 +    'Begin ' +
76 +    ' Select BlobData From TestData Where RowID = :RowID Into :BlobData; '+
77 +    'End';
78 +
79 +
80    sqlGetCharSets = 'Select RDB$CHARACTER_SET_NAME,RDB$CHARACTER_SET_ID from RDB$CHARACTER_SETS order by 2';
81  
82    sqlInsert = 'Insert into TestData(RowID,Title,FixedPoint,FloatingPoint) Values(:RowID,:Title,:FP, :DP)';
83  
84    sqlUpdate = 'Update TestData Set BlobData = ? Where RowID = ?';
85  
86 +  sqlExecProc = 'Execute Procedure TestProc ?';
87 +
88  
89   { TTest6 }
90  
# Line 78 | Line 93 | var Transaction: ITransaction;
93      Statement,
94      Statement2: IStatement;
95      ResultSet: IResultSet;
81    i: integer;
96   begin
97    Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taCommit);
98  
# Line 133 | Line 147 | begin
147    end;
148   end;
149  
150 + procedure TTest6.ExecProc(Attachment: IAttachment);
151 + var Transaction: ITransaction;
152 +    Statement: IStatement;
153 +    Results: IResults;
154 + begin
155 +  writeln(OutFile,'Testing Blob as stored proc parameter');
156 +  Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taCommit);
157 +
158 +  Statement := Attachment.Prepare(Transaction,sqlExecProc);
159 +  PrintMetaData(Statement.GetMetaData);
160 +  Statement.SQLParams[0].AsInteger := 1;
161 +  Results := Statement.Execute;
162 +  ReportResult(Results);
163 + end;
164 +
165   function TTest6.TestTitle: AnsiString;
166   begin
167    Result := 'Test 6: Blob Handling';
# Line 149 | Line 178 | begin
178    DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
179    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
180    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
181 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
182 +  UpdateDatabase(Attachment);
183 +  ExecProc(Attachment);
184 +
185 +  Attachment.DropDatabase;
186 +
187 +  {Repeat with WIN1252}
188 +  DPB := FirebirdAPI.AllocateDPB;
189 +  DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName);
190 +  DPB.Add(isc_dpb_password).setAsString(Owner.GetPassword);
191 +  DPB.Add(isc_dpb_lc_ctype).setAsString('WIN1252');
192 +  DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
193 +  Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
194 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
195 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
196    UpdateDatabase(Attachment);
197 +  ExecProc(Attachment);
198  
199    Attachment.DropDatabase;
200  
# Line 160 | Line 205 | begin
205    DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
206    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
207    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
208 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
209    UpdateDatabase(Attachment);
210 +  ExecProc(Attachment);
211  
212    Attachment.DropDatabase;
213   end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines