ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/udr/testsuite/udrlib/udr_test02.pas
Revision: 371
Committed: Wed Jan 5 15:21:22 2022 UTC (2 years, 3 months ago) by tony
Content type: text/x-pascal
File size: 3015 byte(s)
Log Message:
Beta Release 0.1

File Contents

# Content
1 (*
2 * Firebird UDR Support (fbudrtested). The fbudr components provide a set of
3 * Pascal language bindings for the Firebird API in support of server
4 * side User Defined Routines (UDRs). The fbudr package is an extension
5 * to the Firebird Pascal API.
6 *
7 * The contents of this file are subject to the Initial Developer's
8 * Public License Version 1.0 (the "License"); you may not use this
9 * file except in compliance with the License. You may obtain a copy
10 * of the License here:
11 *
12 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
13 *
14 * Software distributed under the License is distributed on an "AS
15 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16 * implied. See the License for the specific language governing rights
17 * and limitations under the License.
18 *
19 * The Initial Developer of the Original Code is Tony Whyman.
20 *
21 * The Original Code is (C) 2021 Tony Whyman, MWA Software
22 * (http://www.mwasoftware.co.uk).
23 *
24 * All Rights Reserved.
25 *
26 * Contributor(s): ______________________________________.
27 *
28 *)
29 unit udr_test02;
30
31 {$IFDEF MSWINDOWS}
32 {$DEFINE WINDOWS}
33 {$ENDIF}
34
35 {$IFDEF FPC}
36 {$mode delphi}
37 {$codepage UTF8}
38 {$interfaces COM}
39 {$ENDIF}
40
41 interface
42
43 uses
44 Classes, SysUtils, IB, FBUDRController, FBUDRIntf;
45
46 {This unit provides the implementation of selected number of UDR Execute
47 procedures used to test out various aspects of the TFBUDRExecuteProcedure class.
48 Note that each class is registered with the FBUDRController at initialization time.}
49
50 type
51 {TMyTestProcedure is a simple Execute procedure to demonstrate use of the
52 UDR library. The Employee database is assumed. The input parameter selects a
53 row in the EMPLOYEE table and the procedure returns the salary and full name
54 of the selected employee.
55
56 create or alter procedure MyTestProc (
57 EMP_NO SMALLINT
58 ) returns (Salary Numeric(10,2), FullName VarChar(36))
59 external name 'fbudrtests!test_proc'
60 engine udr;
61 }
62
63 TMyTestProcedure = class(TFBUDRExecuteProcedure)
64 public
65 procedure Execute(context: IFBUDRExternalContext;
66 ProcMetadata: IFBUDRProcMetadata;
67 InputParams: IFBUDRInputParams;
68 OutputData: IFBUDROutputData); override;
69 end;
70
71 implementation
72
73 { TMyTestProcedure }
74
75 procedure TMyTestProcedure.Execute(context: IFBUDRExternalContext;
76 ProcMetadata: IFBUDRProcMetadata; InputParams: IFBUDRInputParams;
77 OutputData: IFBUDROutputData);
78 var Results: IResultSet;
79 begin
80 with context do
81 begin
82 Results := GetAttachment.OpenCursorAtStart(GetTransaction,
83 'Select Salary, Full_Name From EMPLOYEE Where EMP_NO = ?',
84 [InputParams.ByName('EMP_NO').AsInteger]);
85 OutputData.ByName('SALARY').AsCurrency := Results.ByName('Salary').AsCurrency;
86 OutputData.ByName('FULLNAME').AsString := Results.ByName('Full_Name').AsString;
87
88 end;
89 end;
90
91 Initialization
92 FBRegisterUDRProcedure('test_proc',TMyTestProcedure);
93
94 end.
95