1 |
(* |
2 |
* Firebird Interface (fbintf). The fbintf components provide a set of |
3 |
* Pascal language bindings for the Firebird API. Although predominantly |
4 |
* a new development they include source code taken from IBX and may be |
5 |
* considered a derived product. This software thus also includes the copyright |
6 |
* notice and license conditions from IBX. |
7 |
* |
8 |
* Except for those parts dervied from IBX, contents of this file are subject |
9 |
* to the Initial Developer's Public License Version 1.0 (the "License"); you |
10 |
* may not use this file except in compliance with the License. You may obtain a |
11 |
* copy of the License here: |
12 |
* |
13 |
* http://www.firebirdsql.org/index.php?op=doc&id=idpl |
14 |
* |
15 |
* Software distributed under the License is distributed on an "AS |
16 |
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
17 |
* implied. See the License for the specific language governing rights |
18 |
* and limitations under the License. |
19 |
* |
20 |
* The Initial Developer of the Original Code is Tony Whyman. |
21 |
* |
22 |
* The Original Code is (C) 2016 Tony Whyman, MWA Software |
23 |
* (http://www.mwasoftware.co.uk). |
24 |
* |
25 |
* All Rights Reserved. |
26 |
* |
27 |
* Contributor(s): ______________________________________. |
28 |
* |
29 |
*) |
30 |
{************************************************************************} |
31 |
{ } |
32 |
{ Borland Delphi Visual Component Library } |
33 |
{ InterBase Express core components } |
34 |
{ } |
35 |
{ Copyright (c) 1998-2000 Inprise Corporation } |
36 |
{ } |
37 |
{ InterBase Express is based in part on the product } |
38 |
{ Free IB Components, written by Gregory H. Deatz for } |
39 |
{ Hoagland, Longo, Moran, Dunst & Doukas Company. } |
40 |
{ Free IB Components is used under license. } |
41 |
{ } |
42 |
{ The contents of this file are subject to the InterBase } |
43 |
{ Public License Version 1.0 (the "License"); you may not } |
44 |
{ use this file except in compliance with the License. You } |
45 |
{ may obtain a copy of the License at http://www.Inprise.com/IPL.html } |
46 |
{ Software distributed under the License is distributed on } |
47 |
{ an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either } |
48 |
{ express or implied. See the License for the specific language } |
49 |
{ governing rights and limitations under the License. } |
50 |
{ The Original Code was created by InterBase Software Corporation } |
51 |
{ and its successors. } |
52 |
{ Portions created by Inprise Corporation are Copyright (C) Inprise } |
53 |
{ Corporation. All Rights Reserved. } |
54 |
{ Contributor(s): Jeff Overcash } |
55 |
{ } |
56 |
{ IBX For Lazarus (Firebird Express) } |
57 |
{ Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk } |
58 |
{ Portions created by MWA Software are copyright McCallum Whyman } |
59 |
{ Associates Ltd 2011 - 2015 } |
60 |
{ } |
61 |
{************************************************************************} |
62 |
unit FBMessages; |
63 |
{$IFDEF MSWINDOWS} |
64 |
{$DEFINE WINDOWS} |
65 |
{$ENDIF} |
66 |
|
67 |
{$IFDEF FPC} |
68 |
{$mode delphi} |
69 |
{$codepage UTF8} |
70 |
{$ENDIF} |
71 |
|
72 |
interface |
73 |
|
74 |
uses |
75 |
Classes, SysUtils; |
76 |
|
77 |
type |
78 |
TIBClientError = ( |
79 |
ibxeInterBaseMissing, |
80 |
ibxeIB60feature, |
81 |
ibxeNotSupported, |
82 |
ibxeNotPermitted, |
83 |
ibxeDatabaseClosed, |
84 |
ibxeNotInTransaction, |
85 |
ibxeTransactionNotAssigned, |
86 |
ibxeEOF, |
87 |
ibxeBOF, |
88 |
ibxeInvalidStatementHandle, |
89 |
ibxeSQLClosed, |
90 |
ibxeUnknownSQLDataType, |
91 |
ibxeInvalidColumnIndex, |
92 |
ibxeInvalidDataConversion, |
93 |
ibxeBlobCannotBeRead, |
94 |
ibxeBlobCannotBeWritten, |
95 |
ibxeBlobNotOpen, |
96 |
ibxeEmptyQuery, |
97 |
ibxeFieldNotFound, |
98 |
ibxeSQLParseError, |
99 |
ibxeIsASelectStatement, |
100 |
ibxeIsAExecuteProcedure, |
101 |
ibxeMaximumEvents, |
102 |
ibxeServiceActive, |
103 |
ibxeServiceInActive, |
104 |
ibxeServerNameMissing, |
105 |
ibxeOutputParsingError, |
106 |
ibxeEmptyAttachmentsList, |
107 |
ibxeInfoBufferTypeError, |
108 |
ibxServiceRequestIndexError, |
109 |
ibxServiceParamTypeError, |
110 |
ibxeOutputBlockIndexError, |
111 |
ibxeOutputBlockTypeError, |
112 |
ibxePBIndexError, |
113 |
ibxePBParamTypeError, |
114 |
ibxeDuplicateParamName, |
115 |
ibxeInvalidArrayDimensions, |
116 |
ibxeNotAMultiDatabaseTransaction, |
117 |
ibxeAttachmentListIndexError, |
118 |
ibxeNotAnArray, |
119 |
ibxeNotABlob, |
120 |
ibxeInvalidSubscript, |
121 |
ibxeArrayElementOverFlow, |
122 |
ibxArrayBoundsCantIncrease , |
123 |
ibxeStatementNotPrepared, |
124 |
ibxeInterfaceOutofDate, |
125 |
ibxeInvalidBlobMetaData, |
126 |
ibxeNoDPB, |
127 |
ibxeInEventWait, |
128 |
ibxeIncompatibleBlob, |
129 |
ibxeMissingColumnName, |
130 |
ibxStringTooLong, |
131 |
ibxFieldNotinDataSet, |
132 |
ibxeNoDefaultCharacterSet, |
133 |
ibxeParamBufferOverflow, |
134 |
ibxeInvalidParamCount, |
135 |
ibxeInvalidVariantType, |
136 |
ibxeInterfaceNotSupported, |
137 |
ibxeCharacterSetExists, |
138 |
ibxeUnknownUserCharSet, |
139 |
ibxeUninitializedInputParameter, |
140 |
ibxeMultiThreadRequired, |
141 |
ibxeTokenQueueOverflow, |
142 |
ibxeTokenQueueUnderflow, |
143 |
ibxErrorParsing, |
144 |
ibxeDLInfoError, |
145 |
ibxeDifferentAPIs, |
146 |
ibxeInvalidDateTimeStr, |
147 |
ibxeBadTimeZoneID, |
148 |
ibxeBadBCDConversion, |
149 |
ibxeBadTimeZoneName, |
150 |
ibxeTimeZoneUnknown, |
151 |
ibxeBadTimeSpecification, |
152 |
ibxeBCDTooBig, |
153 |
ibxeInvalidTimeZoneID, |
154 |
ibxeBadTimestampOrNoTimeZoneDBEntry, |
155 |
ibxeBCDOverflow, |
156 |
ibxeNoTimezoneSupport, |
157 |
ibxeDecFloatNotSupported, |
158 |
ibxeInt128NotSupported, |
159 |
ibxeUnknownParamTypeName, |
160 |
ibxInvalidQueryAction, |
161 |
ibxeSQLTypeUnchangeable, |
162 |
ibxeCannotIncreaseMetadatasize, |
163 |
ibxeBatchModeNotSupported, |
164 |
ibxeNotInBatchMode, |
165 |
ibxeInBatchMode, |
166 |
ibxeInvalidBatchQuery, |
167 |
ibxeBatchRowBufferOverflow, |
168 |
ibxeBatchBufferSizeTooBig |
169 |
); |
170 |
|
171 |
function GetErrorMessage(ErrMess: TIBClientError): AnsiString; |
172 |
|
173 |
{IBError is used internally and by IBX to throw an EIBClientError} |
174 |
|
175 |
procedure IBError(ErrMess: TIBClientError; const Args: array of const); |
176 |
|
177 |
resourcestring |
178 |
{ generic strings used in code } |
179 |
SParamNameExpected = 'Parameter name expected'; |
180 |
sSQLErrorSeparator = ' When Executing: '; |
181 |
SFirebirdAPIFuncNotFound = 'Unable to load Firebird Client Library Function "%s"'; |
182 |
STrue = 'true'; |
183 |
SFalse = 'false'; |
184 |
SArray = '(array)'; |
185 |
SBatchCompletionError = 'Error Processing update/insert batch on row number %d - '; |
186 |
|
187 |
implementation |
188 |
|
189 |
uses IBUtils, IB; |
190 |
|
191 |
resourcestring |
192 |
|
193 |
{ strings used in error messages} |
194 |
SInterBaseMissing = 'Firebird library not found in the path. Please install Firebird to use this functionality'; |
195 |
SIB60feature = '%s is an InterBase 6 function. Please upgrade to InterBase 6 to use this functonality'; |
196 |
SNotSupported = 'Unsupported feature'; |
197 |
SNotPermitted = 'Not permitted'; |
198 |
SDatabaseClosed = 'Cannot perform operation -- DB is not open'; |
199 |
SNotInTransaction = 'Transaction is not active'; |
200 |
STransactionNotAssigned = 'Transaction not assigned'; |
201 |
SEOF = 'End of file'; |
202 |
SBOF = 'Beginning of file'; |
203 |
SInvalidStatementHandle = 'Invalid statement handle'; |
204 |
SSQLClosed = 'IBSQL Closed'; |
205 |
SUnknownSQLDataType = 'Unknown SQL Data type (%d)'; |
206 |
SInvalidColumnIndex = 'Invalid column index (index exceeds permitted range)'; |
207 |
SInvalidDataConversion = 'Invalid data conversion from %s'; |
208 |
SBlobCannotBeRead = 'Blob stream cannot be read'; |
209 |
SBlobCannotBeWritten = 'Blob stream cannot be written'; |
210 |
SBlobNotOpen = 'The Blob is not open'; |
211 |
SEmptyQuery = 'Empty query'; |
212 |
SFieldNotFound = 'Field "%s" not found'; |
213 |
SSQLParseError = 'SQL Parse Error:' + CRLF + CRLF + '%s'; |
214 |
SIsASelectStatement = 'use Open for a Select Statement'; |
215 |
SIsAExecuteProcedure = 'use ExecProc for Procedure; use TQuery for Select procedures'; |
216 |
SMaximumEvents = 'Exceded Maximum Event limits'; |
217 |
SServiceActive = 'Cannot perform operation -- service is not attached'; |
218 |
SServiceInActive = 'Cannot perform operation -- service is attached'; |
219 |
SServerNameMissing = 'Server Name Missing'; |
220 |
SOutputParsingError = 'Unexpected Output buffer value (%d) - %s'; |
221 |
SEmptyAttachmentsList = 'The list of database attachments cannot be empty'; |
222 |
SInfoBufferTypeError = 'Invalid operation for Info Buffer Type (%d)'; |
223 |
SServiceRequestIndexError = 'Service Request Index Out of Range (%d)'; |
224 |
SServiceParamTypeError = 'Invalid Request for Service Param Type'; |
225 |
SOutputBlockIndexError = 'Output Block Index Out of Range (%d)'; |
226 |
SOutputBlockTypeError = 'Invalid Request for Output Block Type'; |
227 |
SPBIndexError = 'DPB Index out of range (%d)'; |
228 |
SPBParamTypeError = 'Invalid Request for DPB Param Type'; |
229 |
SDuplicateParamName = 'Blob or array parameter name must be unique (%s)'; |
230 |
SInvalidArrayDimensions = 'Invalid number of array dimensions (%d)'; |
231 |
SNotAMultiDatabaseTransaction = 'This is not a multi-database transaction'; |
232 |
SAttachmentListIndexError = 'Attachment List index out of range (%d)'; |
233 |
SNotAnArray = 'Table Column must be an array'; |
234 |
SNotABlob = 'Table Column must be a Blob'; |
235 |
SInvalidSubscript = 'Invalid Subscript (%d) for Array Dimension %d'; |
236 |
SArrayElementOverFlow = 'Array Element too big'; |
237 |
SArrayBoundsCantIncrease = 'Array Bounds can only be narrowed'; |
238 |
SStatementNotPrepared = 'The Statement has not been prepared'; |
239 |
SInterfaceOutofDate = 'This interface is no longer up-to-date'; |
240 |
SInvalidBlobMetaData = 'Unable to Access Blob Meta Data'; |
241 |
SNoDPB = 'A DPB must be provided'; |
242 |
SInEventWait = 'Already in Event Wait State'; |
243 |
SIncompatibleBlob = 'Incompatible Blob SubTypes. %d expected, %d found'; |
244 |
SMissingColumnName = 'Relation or Column Name Missing'; |
245 |
SStringTooLong = 'String "%s" is too long. Max %d characters'; |
246 |
SFieldNotinDataSet = 'Field %s is not a member of DataSet %s'; |
247 |
SNoDefaultCharacterSet = 'A connection default character set is required to perform this operation'; |
248 |
SParamBufferOverflow = 'Parameter Buffer Overflow'; |
249 |
SInvalidParamCount = 'Invalid Parameter Count. %d expected, %d found'; |
250 |
SInvalidVariantType = 'Invalid variant type'; |
251 |
SInterfaceNotSupported = 'Interface not supported; Guid %s not found'; |
252 |
SCharacterSetExists = 'Character set "%s" is already defined'; |
253 |
SUnknownUserCharSet = 'Unknown user character set "%s"'; |
254 |
SUninitializedInputParameter = 'SQL Param No. %d (%s) is uninitialised'; |
255 |
SMultiThreadRequired = 'Multi-threading required for %s but not enabled. Please recompile with multi-threading support enabled. '+ |
256 |
'Hint: you probably need to add -dUseCThreads to the Custom Options.'; |
257 |
STokenQueueOverflow = 'Error in SQL Token Analyser - token queue overflow'; |
258 |
STokenQueueUnderflow = 'Error in SQL Token Analyser - token queue underflow'; |
259 |
SErrorParsing = 'Error parsing SQL Statement at clause starting with %s'; |
260 |
SDLInfoError = 'dlinfo returned error - %s'; |
261 |
SDifferentAPIs = 'All transaction attachments must use the same Firebird Library'; |
262 |
SInvalidDateTimeStr = '%s is not a valid Date/Time string'; |
263 |
SBadTimeZoneID = 'Invalid Time Zone ID (%d,%d)'; |
264 |
SBadBCDConversion = 'Conversion to BCD failed'; |
265 |
SBadTimeZoneName = 'Invalid Time Zone Name "%s"'; |
266 |
STimeZoneUnknown = 'Time Zone Unknown'; |
267 |
SBadTimeSpecification = '%d:%d:%d.%d is not a valid time specification'; |
268 |
SBCDTooBig = 'BCD Precision (%d) is too large for Firebird Data Type max precision (%d)'; |
269 |
SInvalidTimeZoneID = 'Invalid Time Zone ID (%d)'; |
270 |
SBadTimestampOrNoTimeZoneDBEntry = 'Bad Timestamp or missing time zone DB entry (%s) TZ ID = %d'; |
271 |
SBCDOverflow = 'BCD Precision too large for Firebird data type,[%s]'; |
272 |
SNoTimezoneSupport = 'TIME/TIMESTAMP WITH TIME ZONE data type not supported'; |
273 |
SDecFloatNotSupported = 'DecFloat Data Type not supported'; |
274 |
SInt128NotSupported = 'INT128 Data Type not supported'; |
275 |
SUnknownParamTypeName = '%s:Unknown Param Type Name "%s"'; |
276 |
SInvalidQueryAction = 'Query Action only valid for an Update or Insert Query'; |
277 |
SSQLTypeUnchangeable = 'Cannot change SQL Type from %s to %s'; |
278 |
SCannotIncreaseMetadatasize = 'Cannot increase Metadata size from %d to %d'; |
279 |
SBatchModeNotSupported = 'Batch Mode is not available. Firebird 4 or later client and server is required'; |
280 |
SNotInBatchMode = 'Not in Batch Mode - have you called AddToBatch?'; |
281 |
SInBatchMode = 'Invalid Operation: a Batch is pending'; |
282 |
SInvalidBatchQuery = 'This query type (%s) cannot be batched'; |
283 |
SBatchRowBufferOverflow = 'Adding Row No. %d - batch buffer size limit (%d bytes) exceeded'; |
284 |
SBatchBufferSizeTooBig = 'Requested Batch Buffer Size (%d bytes) exceeds 256MB limit'; |
285 |
|
286 |
const |
287 |
IBErrorMessages: array[TIBClientError] of string = ( |
288 |
SInterBaseMissing, |
289 |
SIB60feature, |
290 |
SNotSupported, |
291 |
SNotPermitted, |
292 |
SDatabaseClosed, |
293 |
SNotInTransaction, |
294 |
STransactionNotAssigned, |
295 |
SEOF, |
296 |
SBOF, |
297 |
SInvalidStatementHandle, |
298 |
SSQLClosed, |
299 |
SUnknownSQLDataType, |
300 |
SInvalidColumnIndex, |
301 |
SInvalidDataConversion, |
302 |
SBlobCannotBeRead, |
303 |
SBlobCannotBeWritten, |
304 |
SBlobNotOpen, |
305 |
SEmptyQuery, |
306 |
SFieldNotFound, |
307 |
SSQLParseError, |
308 |
SIsASelectStatement, |
309 |
SIsAExecuteProcedure, |
310 |
SMaximumEvents, |
311 |
SServiceActive, |
312 |
SServiceInActive, |
313 |
SServerNameMissing, |
314 |
SOutputParsingError, |
315 |
SEmptyAttachmentsList, |
316 |
SInfoBufferTypeError, |
317 |
SServiceRequestIndexError, |
318 |
SServiceParamTypeError, |
319 |
SOutputBlockIndexError, |
320 |
SOutputBlockTypeError, |
321 |
SPBIndexError, |
322 |
SPBParamTypeError, |
323 |
SDuplicateParamName, |
324 |
SInvalidArrayDimensions, |
325 |
SNotAMultiDatabaseTransaction, |
326 |
SAttachmentListIndexError, |
327 |
SNotAnArray, |
328 |
SNotABlob, |
329 |
SInvalidSubscript, |
330 |
SArrayElementOverFlow, |
331 |
SArrayBoundsCantIncrease, |
332 |
SStatementNotPrepared, |
333 |
SInterfaceOutofDate, |
334 |
SInvalidBlobMetaData, |
335 |
SNoDPB, |
336 |
SInEventWait, |
337 |
SIncompatibleBlob, |
338 |
SMissingColumnName, |
339 |
SStringTooLong, |
340 |
SFieldNotinDataSet, |
341 |
SNoDefaultCharacterSet, |
342 |
SParamBufferOverflow, |
343 |
SInvalidParamCount, |
344 |
SInvalidVariantType, |
345 |
SInterfaceNotSupported, |
346 |
SCharacterSetExists, |
347 |
SUnknownUserCharSet, |
348 |
SUninitializedInputParameter, |
349 |
SMultiThreadRequired, |
350 |
STokenQueueOverflow, |
351 |
STokenQueueUnderflow, |
352 |
SErrorParsing, |
353 |
SDLInfoError, |
354 |
SDifferentAPIs, |
355 |
SInvalidDateTimeStr, |
356 |
SBadTimeZoneID, |
357 |
SBadBCDConversion, |
358 |
SBadTimeZoneName, |
359 |
STimeZoneUnknown, |
360 |
SBadTimeSpecification, |
361 |
SBCDTooBig, |
362 |
SInvalidTimeZoneID, |
363 |
SBadTimestampOrNoTimeZoneDBEntry, |
364 |
SBCDOverflow, |
365 |
SNoTimezoneSupport, |
366 |
SDecFloatNotSupported, |
367 |
SInt128NotSupported, |
368 |
SUnknownParamTypeName, |
369 |
SInvalidQueryAction, |
370 |
SSQLTypeUnchangeable, |
371 |
SCannotIncreaseMetadatasize, |
372 |
SBatchModeNotSupported, |
373 |
SNotInBatchMode, |
374 |
SInBatchMode, |
375 |
SInvalidBatchQuery, |
376 |
SBatchRowBufferOverflow, |
377 |
SBatchBufferSizeTooBig |
378 |
); |
379 |
|
380 |
function GetErrorMessage(ErrMess: TIBClientError): AnsiString; |
381 |
begin |
382 |
Result := IBErrorMessages[ErrMess]; |
383 |
end; |
384 |
|
385 |
procedure IBError(ErrMess: TIBClientError; const Args: array of const); |
386 |
begin |
387 |
raise EIBClientError.Create(Ord(ErrMess), |
388 |
Format(GetErrorMessage(ErrMess), Args)); |
389 |
end; |
390 |
|
391 |
|
392 |
end. |
393 |
|