--- ibx/trunk/fbintf/testsuite/Test6.pas 2017/10/17 10:07:58 68 +++ ibx/trunk/fbintf/testsuite/Test6.pas 2018/01/18 14:37:51 110 @@ -11,7 +11,8 @@ unit Test6; {Test 6: Blob Handling} { - 1. Create an empty database and populate with a single table. + 1. Create an empty database and populate with a single table and stored procedure + returning a blob. 2. Show the character sets available (List RDB$CHARACTER_SETS) @@ -46,6 +47,7 @@ type TTest6 = class(TTestBase) private procedure UpdateDatabase(Attachment: IAttachment); + procedure ExecProc(Attachment: IAttachment); public function TestTitle: AnsiString; override; procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; @@ -64,12 +66,23 @@ const 'Primary Key(RowID)'+ ')'; + sqlCreateProc = + 'Create Procedure TestProc (RowID Integer) '+ + 'Returns (BlobData Blob sub_type 1 Character Set UTF8) '+ + 'As ' + + 'Begin ' + + ' Select BlobData From TestData Where RowID = :RowID Into :BlobData; '+ + 'End'; + + sqlGetCharSets = 'Select RDB$CHARACTER_SET_NAME,RDB$CHARACTER_SET_ID from RDB$CHARACTER_SETS order by 2'; sqlInsert = 'Insert into TestData(RowID,Title,FixedPoint,FloatingPoint) Values(:RowID,:Title,:FP, :DP)'; sqlUpdate = 'Update TestData Set BlobData = ? Where RowID = ?'; + sqlExecProc = 'Execute Procedure TestProc ?'; + { TTest6 } @@ -133,6 +146,21 @@ begin end; end; +procedure TTest6.ExecProc(Attachment: IAttachment); +var Transaction: ITransaction; + Statement: IStatement; + Results: IResults; +begin + writeln('Testing Blob as stored proc parameter'); + Transaction := Attachment.StartTransaction([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],taCommit); + + Statement := Attachment.Prepare(Transaction,sqlExecProc); + PrintMetaData(Statement.GetMetaData); + Statement.SQLParams[0].AsInteger := 1; + Results := Statement.Execute; + ReportResult(Results); +end; + function TTest6.TestTitle: AnsiString; begin Result := 'Test 6: Blob Handling'; @@ -149,7 +177,23 @@ begin DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect); Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB); Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable); + Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc); + UpdateDatabase(Attachment); + ExecProc(Attachment); + + Attachment.DropDatabase; + + {Repeat with WIN1252} + DPB := FirebirdAPI.AllocateDPB; + DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName); + DPB.Add(isc_dpb_password).setAsString(Owner.GetPassword); + DPB.Add(isc_dpb_lc_ctype).setAsString('WIN1252'); + DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect); + Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB); + Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable); + Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc); UpdateDatabase(Attachment); + ExecProc(Attachment); Attachment.DropDatabase; @@ -160,7 +204,9 @@ begin DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect); Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB); Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable); + Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateProc); UpdateDatabase(Attachment); + ExecProc(Attachment); Attachment.DropDatabase; end;