ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/udr/source/FBUDRIntf.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: 7556 byte(s)
Log Message:
Beta Release 0.1

File Contents

# User Rev Content
1 tony 371 (*
2     * Firebird UDR Support (fbudr). 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 FBUDRIntf;
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, Firebird, IB, IBExternals;
45    
46     type
47     {The IFBUDRExternalContext interface provides the Firebird IExternalContext
48     interface as a native pascal interface}
49    
50     IFBUDRExternalContext = interface
51     ['{00b2616d-12e0-436a-8c2c-58670a2be805}']
52     function GetFirebirdAPI: IFirebirdAPI;
53     function GetAttachment: IAttachment;
54     function GetTransaction: ITransaction;
55     function GetUserName: AnsiString;
56     function GetDatabaseName: AnsiString;
57     function GetClientCharSet: AnsiString;
58     function obtainInfoCode: Integer;
59     function getInfo(code: Integer): Pointer;
60     function setInfo(code: Integer; value: Pointer): Pointer;
61     function getStatus: Firebird.IStatus;
62     procedure CheckStatus;
63     function HasConfigFile: boolean;
64     function ReadConfigString(Section, Ident, DefaultValue: AnsiString): AnsiString;
65     function ReadConfigInteger(Section, Ident: AnsiString; DefaultValue: integer): integer;
66     function ReadConfigBool(Section, Ident: AnsiString; DefaultValue: boolean): boolean;
67     procedure WriteToLog(Msg: AnsiString);
68     end;
69    
70     TFBUDRTriggerType = (ttAfter, ttBefore, ttDatabase);
71     IFBUDRMessageMetadata = interface;
72    
73     {The IFBUDRRoutineMetadata interface provides the Firebird IRoutineMetadata
74     interface as a native Pascal interface}
75    
76     IFBUDRRoutineMetadata = interface
77     ['{28a03226-e8df-40e8-b67f-d3dc27886e9f}']
78     function getPackage: AnsiString;
79     function getName: AnsiString;
80     function getEntryPoint: AnsiString; {response is parsed into the following three components}
81     function getModuleName: AnsiString;
82     function getRoutineName: AnsiString;
83     function getInfo: AnsiString;
84     function getBody: AnsiString;
85     function HasInputMetadata: boolean;
86     function HasOutputMetadata: boolean;
87     function HasTriggerMetadata: boolean;
88     function getFBInputMetadata: IFBUDRMessageMetadata;
89     function getFBOutputMetadata: IFBUDRMessageMetadata;
90     function getFBTriggerMetadata: IFBUDRMessageMetadata;
91     function getTriggerTable: AnsiString;
92     function getTriggerType: TFBUDRTriggerType;
93     end;
94    
95     {IFBUDRProcMetadata is a subset of IFBUDRRoutineMetadata and is used to provide
96     additional information for procedure and function calls}
97    
98     IFBUDRProcMetadata = interface
99     ['{d20fc3ae-635e-4841-ad79-b4cd88be75d8}']
100     function getPackage: AnsiString;
101     function getName: AnsiString;
102     function getEntryPoint: AnsiString;
103     function getModuleName: AnsiString;
104     function getRoutineName: AnsiString;
105     function getInfo: AnsiString;
106     function getBody: AnsiString;
107     end;
108    
109     {IFBUDRTriggerMetaData is a subset of IFBUDRRoutineMetadata and is used to provide
110     additional information for triggers}
111    
112     IFBUDRTriggerMetaData = interface
113     ['{9458bad8-809a-469a-b13f-3a3ab95f8d94}']
114     function getName: AnsiString;
115     function getModuleName: AnsiString;
116     function getRoutineName: AnsiString;
117     function getInfo: AnsiString;
118     function getBody: AnsiString;
119     function getTriggerTable: AnsiString;
120     function getTriggerType: TFBUDRTriggerType;
121     end;
122    
123    
124     {IFBUDRInputParams is a subset of the IResults interface and is used to provide
125     the input parameters to an external function, procedure or trigger as a
126     Pascal interface using Pascal native types.}
127    
128     IFBUDRInputParams = interface
129     ['{e49d096e-3a9c-4f75-bb39-db32b1897312}']
130     function getCount: integer;
131     function getSQLData(index: integer): ISQLData;
132     procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
133     function GetTransaction: ITransaction;
134     function GetAttachment: IAttachment;
135     function ByName(Idx: AnsiString): ISQLData;
136     property Data[index: integer]: ISQLData read getSQLData; default;
137     property Count: integer read getCount;
138     end;
139    
140     {IFBUDROutputData is a subset of the ISQLParams interface and is used to return the
141     each output row for an external procedure}
142    
143     IFBUDROutputData = interface
144     ['{8a7d7890-e9a4-430b-8cbc-3874b5f66b31}']
145     function getCount: integer;
146     function getSQLParam(index: integer): ISQLParam;
147     function GetModified: Boolean;
148     function GetHasCaseSensitiveParams: Boolean;
149     function GetTransaction: ITransaction;
150     function GetAttachment: IAttachment;
151     function ByName(Idx: AnsiString): ISQLParam ;
152     procedure Clear;
153     property Modified: Boolean read GetModified;
154     property Params[index: integer]: ISQLParam read getSQLParam; default;
155     property Count: integer read getCount;
156     end;
157    
158     {IFBUDRMetadataBuilder provides the FIrebird IMetadataBuilder interface
159     as a native Pascal Interface}
160    
161     IFBUDRMetadataBuilder = interface
162     ['{a6876fed-fd70-40f0-b965-6c43b8c5c00d}']
163     procedure setType(index: Cardinal; type_: Cardinal);
164     procedure setSubType(index: Cardinal; subType: Integer);
165     procedure setLength(index: Cardinal; length: Cardinal);
166     procedure setCharSet(index: Cardinal; charSet: Cardinal);
167     procedure setScale(index: Cardinal; scale: Integer);
168     procedure truncate(count: Cardinal);
169     procedure moveNameToIndex(name: AnsiString; index: Cardinal);
170     procedure remove(index: Cardinal);
171     function addField:Cardinal;
172     procedure setField(index: Cardinal; field: AnsiString);
173     procedure setRelation(index: Cardinal; relation: AnsiString);
174     procedure setOwner(index: Cardinal; owner: AnsiString);
175     procedure setAlias(index: Cardinal; alias: AnsiString);
176     end;
177    
178     IFBUDRMessageMetadata = interface
179     ['{da84190f-91a3-40ae-9fab-bbfd98a49dcb}']
180     function getCount: Cardinal;
181     function getField(index: Cardinal): AnsiString;
182     function getRelation(index: Cardinal): AnsiString;
183     function getOwner(index: Cardinal): AnsiString;
184     function getAlias(index: Cardinal): AnsiString;
185     function getType(index: Cardinal): Cardinal;
186     function isNullable(index: Cardinal): Boolean;
187     function getSubType(index: Cardinal): Integer;
188     function getLength(index: Cardinal): Cardinal;
189     function getScale(index: Cardinal): Integer;
190     function getCharSet(index: Cardinal): Cardinal;
191     function getOffset(index: Cardinal): Cardinal;
192     function getNullOffset(index: Cardinal): Cardinal;
193     function getBuilder: IFBUDRMetadataBuilder;
194     function getMessageLength: Cardinal;
195     function getAlignment: Cardinal;
196     function getAlignedLength: Cardinal;
197     end;
198    
199    
200    
201     implementation
202    
203     end.
204