1 |
(* |
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 cloneAttachment: IAttachment; |
62 |
function GetServiceManager: IServiceManager; |
63 |
function getStatus: Firebird.IStatus; |
64 |
procedure CheckStatus; |
65 |
function HasConfigFile: boolean; |
66 |
function ReadConfigString(Section, Ident, DefaultValue: AnsiString): AnsiString; |
67 |
function ReadConfigInteger(Section, Ident: AnsiString; DefaultValue: integer): integer; |
68 |
function ReadConfigBool(Section, Ident: AnsiString; DefaultValue: boolean): boolean; |
69 |
procedure WriteToLog(Msg: AnsiString); |
70 |
end; |
71 |
|
72 |
TFBUDRTriggerType = (ttAfter, ttBefore, ttDatabase); |
73 |
IFBUDRMessageMetadata = interface; |
74 |
|
75 |
{The IFBUDRRoutineMetadata interface provides the Firebird IRoutineMetadata |
76 |
interface as a native Pascal interface} |
77 |
|
78 |
IFBUDRRoutineMetadata = interface |
79 |
['{28a03226-e8df-40e8-b67f-d3dc27886e9f}'] |
80 |
function getPackage: AnsiString; |
81 |
function getName: AnsiString; |
82 |
function getEntryPoint: AnsiString; {response is parsed into the following three components} |
83 |
function getModuleName: AnsiString; |
84 |
function getRoutineName: AnsiString; |
85 |
function getInfo: AnsiString; |
86 |
function getBody: AnsiString; |
87 |
function HasInputMetadata: boolean; |
88 |
function HasOutputMetadata: boolean; |
89 |
function HasTriggerMetadata: boolean; |
90 |
function getFBInputMetadata: IFBUDRMessageMetadata; |
91 |
function getFBOutputMetadata: IFBUDRMessageMetadata; |
92 |
function getFBTriggerMetadata: IFBUDRMessageMetadata; |
93 |
function getTriggerTable: AnsiString; |
94 |
function getTriggerType: TFBUDRTriggerType; |
95 |
end; |
96 |
|
97 |
{IFBUDRProcMetadata is a subset of IFBUDRRoutineMetadata and is used to provide |
98 |
additional information for procedure and function calls} |
99 |
|
100 |
IFBUDRProcMetadata = interface |
101 |
['{d20fc3ae-635e-4841-ad79-b4cd88be75d8}'] |
102 |
function getPackage: AnsiString; |
103 |
function getName: AnsiString; |
104 |
function getEntryPoint: AnsiString; |
105 |
function getModuleName: AnsiString; |
106 |
function getRoutineName: AnsiString; |
107 |
function getInfo: AnsiString; |
108 |
end; |
109 |
|
110 |
{IFBUDRTriggerMetaData is a subset of IFBUDRRoutineMetadata and is used to provide |
111 |
additional information for triggers} |
112 |
|
113 |
IFBUDRTriggerMetaData = interface |
114 |
['{9458bad8-809a-469a-b13f-3a3ab95f8d94}'] |
115 |
function getName: AnsiString; |
116 |
function getModuleName: AnsiString; |
117 |
function getRoutineName: AnsiString; |
118 |
function getInfo: 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 |
function ParamExists(Idx: AnsiString): boolean; |
133 |
function ByName(Idx: AnsiString): ISQLData; |
134 |
property Data[index: integer]: ISQLData read getSQLData; default; |
135 |
property Count: integer read getCount; |
136 |
end; |
137 |
|
138 |
{IFBUDROutputData is a subset of the ISQLParams interface and is used to return the |
139 |
each output row for an external procedure} |
140 |
|
141 |
IFBUDROutputData = interface |
142 |
['{8a7d7890-e9a4-430b-8cbc-3874b5f66b31}'] |
143 |
function getCount: integer; |
144 |
function getSQLParam(index: integer): ISQLParam; |
145 |
function GetModified: Boolean; |
146 |
function GetHasCaseSensitiveParams: Boolean; |
147 |
function FieldExists(Idx: AnsiString): boolean; |
148 |
function ByName(Idx: AnsiString): ISQLParam ; |
149 |
procedure Clear; |
150 |
property Modified: Boolean read GetModified; |
151 |
property Params[index: integer]: ISQLParam read getSQLParam; default; |
152 |
property Count: integer read getCount; |
153 |
end; |
154 |
|
155 |
{IFBUDRMetadataBuilder provides the FIrebird IMetadataBuilder interface |
156 |
as a native Pascal Interface} |
157 |
|
158 |
IFBUDRMetadataBuilder = interface |
159 |
['{a6876fed-fd70-40f0-b965-6c43b8c5c00d}'] |
160 |
procedure setType(index: Cardinal; type_: Cardinal); |
161 |
procedure setSubType(index: Cardinal; subType: Integer); |
162 |
procedure setLength(index: Cardinal; length: Cardinal); |
163 |
procedure setCharSet(index: Cardinal; charSet: Cardinal); |
164 |
procedure setScale(index: Cardinal; scale: Integer); |
165 |
procedure truncate(count: Cardinal); |
166 |
procedure moveNameToIndex(name: AnsiString; index: Cardinal); |
167 |
procedure remove(index: Cardinal); |
168 |
function addField:Cardinal; |
169 |
procedure setField(index: Cardinal; field: AnsiString); |
170 |
procedure setRelation(index: Cardinal; relation: AnsiString); |
171 |
procedure setOwner(index: Cardinal; owner: AnsiString); |
172 |
procedure setAlias(index: Cardinal; alias: AnsiString); |
173 |
end; |
174 |
|
175 |
IFBUDRMessageMetadata = interface |
176 |
['{da84190f-91a3-40ae-9fab-bbfd98a49dcb}'] |
177 |
function getCount: Cardinal; |
178 |
function getField(index: Cardinal): AnsiString; |
179 |
function getRelation(index: Cardinal): AnsiString; |
180 |
function getOwner(index: Cardinal): AnsiString; |
181 |
function getAlias(index: Cardinal): AnsiString; |
182 |
function getType(index: Cardinal): Cardinal; |
183 |
function isNullable(index: Cardinal): Boolean; |
184 |
function getSubType(index: Cardinal): Integer; |
185 |
function getLength(index: Cardinal): Cardinal; |
186 |
function getScale(index: Cardinal): Integer; |
187 |
function getCharSet(index: Cardinal): Cardinal; |
188 |
function getOffset(index: Cardinal): Cardinal; |
189 |
function getNullOffset(index: Cardinal): Cardinal; |
190 |
function getBuilder: IFBUDRMetadataBuilder; |
191 |
function getMessageLength: Cardinal; |
192 |
function getAlignment: Cardinal; |
193 |
function getAlignedLength: Cardinal; |
194 |
end; |
195 |
|
196 |
|
197 |
|
198 |
implementation |
199 |
|
200 |
end. |
201 |
|