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 110 by tony, Thu Jan 18 14:37:51 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 46 | Line 47 | type
47    TTest6 = class(TTestBase)
48    private
49      procedure UpdateDatabase(Attachment: IAttachment);
50 +    procedure ExecProc(Attachment: IAttachment);
51    public
52      function TestTitle: AnsiString; override;
53      procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
# Line 64 | Line 66 | const
66      'Primary Key(RowID)'+
67      ')';
68  
69 +  sqlCreateProc =
70 +    'Create Procedure TestProc (RowID Integer) '+
71 +    'Returns (BlobData Blob sub_type 1 Character Set UTF8) '+
72 +    'As ' +
73 +    'Begin ' +
74 +    ' Select BlobData From TestData Where RowID = :RowID Into :BlobData; '+
75 +    'End';
76 +
77 +
78    sqlGetCharSets = 'Select RDB$CHARACTER_SET_NAME,RDB$CHARACTER_SET_ID from RDB$CHARACTER_SETS order by 2';
79  
80    sqlInsert = 'Insert into TestData(RowID,Title,FixedPoint,FloatingPoint) Values(:RowID,:Title,:FP, :DP)';
81  
82    sqlUpdate = 'Update TestData Set BlobData = ? Where RowID = ?';
83  
84 +  sqlExecProc = 'Execute Procedure TestProc ?';
85 +
86  
87   { TTest6 }
88  
# Line 133 | Line 146 | begin
146    end;
147   end;
148  
149 + procedure TTest6.ExecProc(Attachment: IAttachment);
150 + var Transaction: ITransaction;
151 +    Statement: IStatement;
152 +    Results: IResults;
153 + begin
154 +  writeln('Testing Blob as stored proc parameter');
155 +  Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taCommit);
156 +
157 +  Statement := Attachment.Prepare(Transaction,sqlExecProc);
158 +  PrintMetaData(Statement.GetMetaData);
159 +  Statement.SQLParams[0].AsInteger := 1;
160 +  Results := Statement.Execute;
161 +  ReportResult(Results);
162 + end;
163 +
164   function TTest6.TestTitle: AnsiString;
165   begin
166    Result := 'Test 6: Blob Handling';
# Line 149 | Line 177 | begin
177    DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
178    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
179    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
180 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
181 +  UpdateDatabase(Attachment);
182 +  ExecProc(Attachment);
183 +
184 +  Attachment.DropDatabase;
185 +
186 +  {Repeat with WIN1252}
187 +  DPB := FirebirdAPI.AllocateDPB;
188 +  DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName);
189 +  DPB.Add(isc_dpb_password).setAsString(Owner.GetPassword);
190 +  DPB.Add(isc_dpb_lc_ctype).setAsString('WIN1252');
191 +  DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
192 +  Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
193 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
194 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
195    UpdateDatabase(Attachment);
196 +  ExecProc(Attachment);
197  
198    Attachment.DropDatabase;
199  
# Line 160 | Line 204 | begin
204    DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect);
205    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
206    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
207 +  Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc);
208    UpdateDatabase(Attachment);
209 +  ExecProc(Attachment);
210  
211    Attachment.DropDatabase;
212   end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines