ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/nongui/IBUpdate.pas
Revision: 349
Committed: Mon Oct 18 08:39:40 2021 UTC (2 years, 6 months ago) by tony
Content type: text/x-pascal
File size: 20104 byte(s)
Log Message:
FIxes Merged

File Contents

# Content
1 (*
2 * IBX For Lazarus (Firebird Express)
3 *
4 * The contents of this file are subject to the Initial Developer's
5 * Public License Version 1.0 (the "License"); you may not use this
6 * file except in compliance with the License. You may obtain a copy
7 * of the License here:
8 *
9 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
10 *
11 * Software distributed under the License is distributed on an "AS
12 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13 * implied. See the License for the specific language governing rights
14 * and limitations under the License.
15 *
16 * The Initial Developer of the Original Code is Tony Whyman.
17 *
18 * The Original Code is (C) 2015-2020 Tony Whyman, MWA Software
19 * (http://www.mwasoftware.co.uk).
20 *
21 * All Rights Reserved.
22 *
23 * Contributor(s): ______________________________________.
24 *
25 *)
26
27 unit IBUpdate;
28
29 {$mode objfpc}{$H+}
30
31 interface
32
33 uses
34 Classes, SysUtils, IBCustomDataSet, DB, IB, IBDatabase, IBExternals, IBMessages;
35
36 type
37
38 TOnApplyUpdates = procedure(Sender: TObject; UpdateKind: TUpdateKind; Params: ISQLParams) of object;
39
40 { TIBUpdate}
41
42 TIBUpdate = class(TIBDataSetUpdateObject)
43 private
44 FDataSet: TIBCustomDataSet;
45 FDummySQL: TStrings;
46 FOnApplyUpdates: TOnApplyUpdates;
47 protected
48 function GetSQL(UpdateKind: TUpdateKind): TStrings; override;
49 function GetDataSet: TIBCustomDataSet; override;
50 procedure SetDataSet(ADataSet: TIBCustomDataSet); override;
51 procedure Apply(UpdateKind: TUpdateKind; buff: PChar); override;
52 public
53 constructor Create(AOwner: TComponent); override;
54 destructor Destroy; override;
55 property DataSet;
56 published
57 property OnApplyUpdates: TOnApplyUpdates read FOnApplyUpdates write FOnApplyUpdates;
58 end;
59
60
61 implementation
62
63 uses variants, FmtBCD, DateUtils;
64
65 type
66
67 { TParamListIntf }
68
69 TParamListIntf = class(TInterfacedObject,ISQLParams)
70 private
71 type TParamRec = record
72 Name: string;
73 Value: variant;
74 Modified: boolean;
75 TimeZoneID: TFBTimeZoneID;
76 DataSet: TDataSet;
77 end;
78 private
79 FDatabase: TIBDatabase;
80 FModified: boolean;
81 FParams: array of TParamRec;
82 procedure SetParam(index: integer; aValue: variant);
83 procedure SetTimeZoneID(index: integer; aValue: TFBTimeZoneID);
84 public
85 constructor Create(aFields: TFields; aDatabase: TIBDatabase);
86 destructor Destroy; override;
87 property Database: TIBDatabase read FDatabase;
88 public
89 {ISQLParams}
90 function getCount: integer;
91 function getSQLParam(index: integer): ISQLParam;
92 function ByName(Idx: AnsiString): ISQLParam ;
93 function GetModified: Boolean;
94 function GetHasCaseSensitiveParams: Boolean;
95 end;
96
97 { TParamIntf }
98
99 TParamIntf = class(TInterfacedObject,ISQLParam)
100 private
101 FIndex: integer;
102 FOwner: TParamListIntf;
103 function GetDataSet: TDataSet;
104 public
105 constructor Create(aOwner: TParamListIntf; aIndex: integer);
106 function getColMetadata: IParamMetaData;
107 function GetIndex: integer;
108 function GetSQLType: cardinal;
109 function GetSQLTypeName: AnsiString;
110 function getSubtype: integer;
111 function getName: AnsiString;
112 function getScale: integer;
113 function getCharSetID: cardinal;
114 function getCodePage: TSystemCodePage;
115 function getIsNullable: boolean;
116 function GetSize: cardinal;
117 function GetAsBoolean: boolean;
118 function GetAsCurrency: Currency;
119 function GetAsInt64: Int64;
120 function GetAsDateTime: TDateTime; overload;
121 procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
122 procedure GetAsDateTime(var aDateTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
123 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime); overload;
124 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString; OnDate: TDateTime); overload;
125 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID); overload;
126 procedure GetAsTime(var aTime: TDateTime; var dstOffset: smallint; var aTimezone: AnsiString); overload;
127 function GetAsUTCDateTime: TDateTime;
128 function GetAsDouble: Double;
129 function GetAsFloat: Float;
130 function GetAsLong: Long;
131 function GetAsPointer: Pointer;
132 function GetAsQuad: TISC_QUAD;
133 function GetAsShort: short;
134 function GetAsString: AnsiString;
135 function GetIsNull: boolean;
136 function GetAsVariant: Variant;
137 function GetAsBlob: IBlob;
138 function GetAsArray: IArray;
139 function GetAsBCD: tBCD;
140 function GetStatement: IStatement;
141 function GetTransaction: ITransaction;
142 procedure Clear;
143 function GetModified: boolean;
144 procedure SetAsBoolean(AValue: boolean);
145 procedure SetAsCurrency(aValue: Currency);
146 procedure SetAsInt64(aValue: Int64);
147 procedure SetAsDate(aValue: TDateTime);
148 procedure SetAsLong(aValue: Long);
149 procedure SetAsTime(aValue: TDateTime); overload;
150 procedure SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
151 procedure SetAsTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
152 procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
153 procedure SetAsTime(aValue: TDateTime; OnDate: TDateTime; aTimeZone: AnsiString); overload;
154 procedure SetAsDateTime(aValue: TDateTime); overload;
155 procedure SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID); overload;
156 procedure SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString); overload;
157 procedure SetAsUTCDateTime(aUTCTime: TDateTime);
158 procedure SetAsDouble(aValue: Double);
159 procedure SetAsFloat(aValue: Float);
160 procedure SetAsPointer(aValue: Pointer);
161 procedure SetAsShort(aValue: Short);
162 procedure SetAsString(aValue: AnsiString);
163 procedure SetAsVariant(aValue: Variant);
164 procedure SetIsNull(aValue: Boolean);
165 procedure SetAsBlob(aValue: IBlob);
166 procedure SetAsArray(anArray: IArray);
167 procedure SetAsQuad(aValue: TISC_QUAD);
168 procedure SetCharSetID(aValue: cardinal);
169 procedure SetAsBcd(aValue: tBCD);
170 end;
171
172 { TParamIntf }
173
174 function TParamIntf.GetDataSet: TDataSet;
175 begin
176 Result := FOwner.FParams[FIndex].DataSet;
177 end;
178
179 constructor TParamIntf.Create(aOwner: TParamListIntf; aIndex: integer);
180 begin
181 FOwner := aOwner;
182 FIndex := aIndex;
183 end;
184
185 function TParamIntf.getColMetadata: IParamMetaData;
186 begin
187 IBError(ibxeNotSupported,[]);
188 end;
189
190 function TParamIntf.GetIndex: integer;
191 begin
192 Result := Findex;
193 end;
194
195 function TParamIntf.GetSQLType: cardinal;
196 begin
197 IBError(ibxeNotSupported,[]);
198 end;
199
200 function TParamIntf.GetSQLTypeName: AnsiString;
201 begin
202 IBError(ibxeNotSupported,[]);
203 end;
204
205 function TParamIntf.getSubtype: integer;
206 begin
207 IBError(ibxeNotSupported,[]);
208 end;
209
210 function TParamIntf.getName: AnsiString;
211 begin
212 Result := FOwner.FParams[FIndex].Name;
213 end;
214
215 function TParamIntf.getScale: integer;
216 begin
217 IBError(ibxeNotSupported,[]);
218 end;
219
220 function TParamIntf.getCharSetID: cardinal;
221 var id: integer;
222 begin
223 FOwner.Database.Attachment.CodePage2CharSetID(StringCodePage(FOwner.FParams[FIndex].Value),id);
224 Result := id;
225 end;
226
227 function TParamIntf.getCodePage: TSystemCodePage;
228 begin
229 Result := StringCodePage(FOwner.FParams[FIndex].Value);
230 end;
231
232 function TParamIntf.getIsNullable: boolean;
233 begin
234 Result := true;
235 end;
236
237 function TParamIntf.GetSize: cardinal;
238 begin
239 IBError(ibxeNotSupported,[]);
240 end;
241
242 function TParamIntf.GetAsBoolean: boolean;
243 begin
244 Result := FOwner.FParams[FIndex].Value;
245 end;
246
247 function TParamIntf.GetAsCurrency: Currency;
248 begin
249 Result := FOwner.FParams[FIndex].Value;
250 end;
251
252 function TParamIntf.GetAsInt64: Int64;
253 begin
254 Result := FOwner.FParams[FIndex].Value;
255 end;
256
257 function TParamIntf.GetAsDateTime: TDateTime;
258 begin
259 Result := FOwner.FParams[FIndex].Value;
260 end;
261
262 procedure TParamIntf.GetAsDateTime(var aDateTime: TDateTime;
263 var dstOffset: smallint; var aTimezoneID: TFBTimeZoneID);
264 begin
265 with FOwner.FParams[FIndex] do
266 if VarIsArray(Value) then
267 begin
268 aDateTime := Value[0];
269 dstOffset := Value[1];
270 if VarType(Value[2]) in [varSmallint, varInteger, varByte, varWord, varShortInt] then
271 aTimezoneID := Value[2]
272 else
273 aTimeZoneID := FOwner.DataBase.attachment.GetTimeZoneServices.TimeZoneName2TimeZoneID(Value[2]);
274 end
275 else
276 begin
277 aDateTime := FOwner.FParams[FIndex].Value;
278 dstOffset := 0;
279 aTimeZoneID := TimeZoneID_GMT;
280 end;
281 end;
282
283 procedure TParamIntf.GetAsDateTime(var aDateTime: TDateTime;
284 var dstOffset: smallint; var aTimezone: AnsiString);
285 begin
286 with FOwner.FParams[FIndex] do
287 if VarIsArray(Value) then
288 begin
289 aDateTime := Value[0];
290 dstOffset := Value[1];
291 if VarType(Value[2]) in [varSmallint, varInteger, varByte, varWord, varShortInt] then
292 aTimeZone := FOwner.DataBase.attachment.GetTimeZoneServices.TimeZoneID2TimeZoneName(Value[2])
293 else
294 aTimezone := Value[2];
295 end
296 else
297 begin
298 aDateTime := FOwner.FParams[FIndex].Value;
299 dstOffset := 0;
300 aTimeZone := 'GMT';
301 end;
302 end;
303
304 procedure TParamIntf.GetAsTime(var aTime: TDateTime; var dstOffset: smallint;
305 var aTimezoneID: TFBTimeZoneID; OnDate: TDateTime);
306 var LocalTime: TDateTime;
307 begin
308 with FOwner.FParams[FIndex] do
309 if VarIsArray(Value) then
310 begin
311 LocalTime := OnDate + TimeOf(Value[0]);
312 dstOffset := Value[1];
313 if VarType(Value[2]) in [varSmallint, varInteger, varByte, varWord, varShortInt] then
314 aTimezoneID := Value[2]
315 else
316 aTimeZoneID := FOwner.DataBase.attachment.GetTimeZoneServices.TimeZoneName2TimeZoneID(Value[2]);
317 aTime := TimeOf(FOwner.DataBase.attachment.GetTimeZoneServices.GMTToLocalTime(IncMinute(LocalTime,-dstOffset),aTimeZoneID))
318 end
319 else
320 begin
321 aTime := FOwner.FParams[FIndex].Value;
322 dstOffset := 0;
323 aTimeZoneID := TimeZoneID_GMT;
324 end;
325 end;
326
327 procedure TParamIntf.GetAsTime(var aTime: TDateTime; var dstOffset: smallint;
328 var aTimezone: AnsiString; OnDate: TDateTime);
329 var LocalTime: TDateTime;
330 begin
331 with FOwner.FParams[FIndex] do
332 if VarIsArray(Value) then
333 begin
334 LocalTime := OnDate + TimeOf(Value[0]);
335 dstOffset := Value[1];
336 if VarType(Value[2]) in [varSmallint, varInteger, varByte, varWord, varShortInt] then
337 aTimeZone := FOwner.DataBase.attachment.GetTimeZoneServices.TimeZoneID2TimeZoneName(Value[2])
338 else
339 aTimezone := Value[2];
340 aTime := TimeOf(FOwner.DataBase.attachment.GetTimeZoneServices.GMTToLocalTime(IncMinute(LocalTime,-dstOffset),aTimeZone))
341 end
342 else
343 begin
344 aTime := FOwner.FParams[FIndex].Value;
345 dstOffset := 0;
346 aTimeZone := 'GMT';
347 end;
348 end;
349
350 procedure TParamIntf.GetAsTime(var aTime: TDateTime; var dstOffset: smallint;
351 var aTimezoneID: TFBTimeZoneID);
352 begin
353 GetAsTime(aTime,dstOffset,aTimeZoneID,(GetDataSet as TIBCustomDataSet).DefaultTZDate);
354 end;
355
356 procedure TParamIntf.GetAsTime(var aTime: TDateTime; var dstOffset: smallint;
357 var aTimezone: AnsiString);
358 begin
359 GetAsTime(aTime,dstOffset,aTimeZone,(GetDataSet as TIBCustomDataSet).DefaultTZDate);
360 end;
361
362 function TParamIntf.GetAsUTCDateTime: TDateTime;
363 begin
364 with FOwner.FParams[FIndex] do
365 if VarIsArray(Value) then
366 Result := IncMinute(Value[0],-Value[1])
367 else
368 Result := FOwner.FParams[FIndex].Value;
369 end;
370
371 function TParamIntf.GetAsDouble: Double;
372 begin
373 Result := FOwner.FParams[FIndex].Value;
374 end;
375
376 function TParamIntf.GetAsFloat: Float;
377 begin
378 Result := FOwner.FParams[FIndex].Value;
379 end;
380
381 function TParamIntf.GetAsLong: Long;
382 begin
383 Result := FOwner.FParams[FIndex].Value;
384 end;
385
386 function TParamIntf.GetAsPointer: Pointer;
387 begin
388 IBError(ibxeNotSupported,[]);
389 end;
390
391 function TParamIntf.GetAsQuad: TISC_QUAD;
392 begin
393 IBError(ibxeNotSupported,[]);
394 end;
395
396 function TParamIntf.GetAsShort: short;
397 begin
398 Result := FOwner.FParams[FIndex].Value;
399 end;
400
401 function TParamIntf.GetAsString: AnsiString;
402 var v: variant;
403 begin
404 v := FOwner.FParams[FIndex].Value;
405 Case varType(v) of
406 varEmpty,
407 varNull:
408 Result := '';
409 varShortInt,
410 varSmallint,
411 varInteger,
412 varInt64,
413 varByte,
414 varWord,
415 varDecimal,
416 varLongWord,
417 varQWord,
418 varSingle:
419 Result := IntToStr(v);
420 varCurrency,
421 varDouble:
422 Result := FloatToStr(v);
423 varDate:
424 Result := DateTimeToStr(v);
425 varStrArg,
426 varString:
427 Result := v;
428 varBoolean:
429 if v then
430 Result := 'true'
431 else
432 Result := 'false';
433 varVariant:
434 Result := v;
435 else
436 Result := v;
437 end;
438 end;
439
440 function TParamIntf.GetIsNull: boolean;
441 begin
442 Result := VarIsNull(FOwner.FParams[FIndex].Value);
443 end;
444
445 function TParamIntf.GetAsVariant: Variant;
446 begin
447 Result := FOwner.FParams[FIndex].Value;
448 end;
449
450 function TParamIntf.GetAsBlob: IBlob;
451 begin
452 IBError(ibxeNotSupported,[]);
453 end;
454
455 function TParamIntf.GetAsArray: IArray;
456 begin
457 IBError(ibxeNotSupported,[]);
458 end;
459
460 function TParamIntf.GetAsBCD: tBCD;
461 begin
462 Result := VarToBCD(FOwner.FParams[FIndex].Value);
463 end;
464
465 function TParamIntf.GetStatement: IStatement;
466 begin
467 IBError(ibxeNotSupported,[]);
468 end;
469
470 function TParamIntf.GetTransaction: ITransaction;
471 begin
472 IBError(ibxeNotSupported,[]);
473 end;
474
475 procedure TParamIntf.Clear;
476 begin
477 FOwner.SetParam(FIndex,NULL);
478 end;
479
480 function TParamIntf.GetModified: boolean;
481 begin
482 Result := FOwner.FParams[FIndex].Modified;
483 end;
484
485 procedure TParamIntf.SetAsBoolean(AValue: boolean);
486 begin
487 FOwner.SetParam(FIndex,AValue);
488 end;
489
490 procedure TParamIntf.SetAsCurrency(aValue: Currency);
491 begin
492 FOwner.SetParam(FIndex,AValue);
493 end;
494
495 procedure TParamIntf.SetAsInt64(aValue: Int64);
496 begin
497 FOwner.SetParam(FIndex,AValue);
498 end;
499
500 procedure TParamIntf.SetAsDate(aValue: TDateTime);
501 begin
502 FOwner.SetParam(FIndex,AValue);
503 end;
504
505 procedure TParamIntf.SetAsLong(aValue: Long);
506 begin
507 FOwner.SetParam(FIndex,AValue);
508 end;
509
510 procedure TParamIntf.SetAsTime(aValue: TDateTime);
511 begin
512 FOwner.SetParam(FIndex,AValue);
513 end;
514
515 procedure TParamIntf.SetAsTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID);
516 begin
517 SetAsTime(aValue,(GetDataSet as TIBCustomDataSet).DefaultTZDate,aTimeZoneID);
518 end;
519
520 procedure TParamIntf.SetAsTime(aValue: TDateTime; aTimeZone: AnsiString);
521 begin
522 SetAsTime(aValue,(GetDataSet as TIBCustomDataSet).DefaultTZDate,aTimeZone);
523 end;
524
525 procedure TParamIntf.SetAsTime(aValue: TDateTime; OnDate: TDateTime;
526 aTimeZoneID: TFBTimeZoneID);
527 var dstOffset: smallint;
528 begin
529 aValue := TimeOf(aValue);
530 dstOffset := FOwner.Database.Attachment.GetTimeZoneServices.GetEffectiveOffsetMins(OnDate + aValue,aTimeZoneID);
531 FOwner.SetParam(FIndex,VarArrayOf([aValue,dstOffset,aTimeZoneID]));
532 end;
533
534 procedure TParamIntf.SetAsTime(aValue: TDateTime; OnDate: TDateTime;
535 aTimeZone: AnsiString);
536 var dstOffset: smallint;
537 begin
538 aValue := TimeOf(aValue);
539 dstOffset := FOwner.Database.Attachment.GetTimeZoneServices.GetEffectiveOffsetMins(OnDate + aValue,aTimeZone);
540 FOwner.SetParam(FIndex,VarArrayOf([aValue,dstOffset,aTimeZone]));
541 end;
542
543 procedure TParamIntf.SetAsDateTime(aValue: TDateTime);
544 begin
545 FOwner.SetParam(FIndex,AValue);
546 end;
547
548 procedure TParamIntf.SetAsDateTime(aValue: TDateTime; aTimeZoneID: TFBTimeZoneID
549 );
550 var dstOffset: smallint;
551 begin
552 with FOwner.DataBase.attachment.GetTimeZoneServices do
553 begin
554 dstOffset := GetEffectiveOffsetMins(aValue,aTimeZoneID);
555 FOwner.SetParam(FIndex,VarArrayOf([aValue,aTimeZoneID]));
556 end;
557 end;
558
559 procedure TParamIntf.SetAsDateTime(aValue: TDateTime; aTimeZone: AnsiString);
560 var dstOffset: smallint;
561 begin
562 with FOwner.DataBase.attachment.GetTimeZoneServices do
563 begin
564 dstOffset := GetEffectiveOffsetMins(aValue,aTimeZone);
565 FOwner.SetParam(FIndex,VarArrayOf([aValue,aTimeZone]));
566 end;
567 end;
568
569 procedure TParamIntf.SetAsUTCDateTime(aUTCTime: TDateTime);
570 begin
571 IBError(ibxeNotSupported,[]);
572 end;
573
574 procedure TParamIntf.SetAsDouble(aValue: Double);
575 begin
576 FOwner.SetParam(FIndex,AValue);
577 end;
578
579 procedure TParamIntf.SetAsFloat(aValue: Float);
580 begin
581 FOwner.SetParam(FIndex,AValue);
582 end;
583
584 procedure TParamIntf.SetAsPointer(aValue: Pointer);
585 begin
586 IBError(ibxeNotSupported,[]);
587 end;
588
589 procedure TParamIntf.SetAsShort(aValue: Short);
590 begin
591 FOwner.SetParam(FIndex,AValue);
592 end;
593
594 procedure TParamIntf.SetAsString(aValue: AnsiString);
595 begin
596 FOwner.SetParam(FIndex,AValue);
597 end;
598
599 procedure TParamIntf.SetAsVariant(aValue: Variant);
600 begin
601 FOwner.SetParam(FIndex,AValue);
602 end;
603
604 procedure TParamIntf.SetIsNull(aValue: Boolean);
605 begin
606 if aValue then
607 FOwner.SetParam(FIndex,NULL)
608 end;
609
610 procedure TParamIntf.SetAsBlob(aValue: IBlob);
611 begin
612 IBError(ibxeNotSupported,[]);
613 end;
614
615 procedure TParamIntf.SetAsArray(anArray: IArray);
616 begin
617 IBError(ibxeNotSupported,[]);
618 end;
619
620 procedure TParamIntf.SetAsQuad(aValue: TISC_QUAD);
621 begin
622 IBError(ibxeNotSupported,[]);
623 end;
624
625 procedure TParamIntf.SetCharSetID(aValue: cardinal);
626 var s: RawByteString;
627 codepage: TSystemCodePage;
628 str: string;
629 begin
630 str := FOwner.FParams[FIndex].Value;
631 s := str;
632 if FOwner.Database.Attachment.CharSetID2CodePage(aValue,codepage) then
633 SetCodePage(s,codepage,codepage <> cp_none);
634 end;
635
636 procedure TParamIntf.SetAsBcd(aValue: tBCD);
637 begin
638 FOwner.SetParam(FIndex,VarFmtBCDCreate(AValue));
639 end;
640
641 { TParamListIntf }
642
643 procedure TParamListIntf.SetParam(index: integer; aValue: variant);
644 begin
645 FParams[index].Value := aValue;
646 FParams[index].Modified := true;
647 FParams[index].TimeZoneID := TimeZoneID_GMT;
648 FModified := true;
649 end;
650
651 procedure TParamListIntf.SetTimeZoneID(index: integer; aValue: TFBTimeZoneID);
652 begin
653 if FParams[index].Modified then
654 FParams[index].TimeZoneID := aValue;
655 end;
656
657 constructor TParamListIntf.Create(aFields: TFields; aDatabase: TIBDatabase);
658 var i,j: integer;
659 begin
660 inherited Create;
661 FDatabase := aDatabase;
662 SetLength(FParams,aFields.Count*2);
663 j := 0;
664 {set up both current and "OLD" parameters from Field Names}
665 for i := 0 to aFields.Count - 1 do
666 if aFields[i].FieldKind = fkData then
667 begin
668 FParams[j].Name := aFields[i].FieldName;
669 FParams[j].Value := NULL;
670 FParams[j].Modified := false;
671 FParams[j].DataSet := aFields[i].DataSet;
672 Inc(j);
673 FParams[j].Name := 'OLD_' + aFields[i].FieldName;
674 FParams[j].Value := NULL;
675 FParams[j].Modified := false;
676 FParams[j].DataSet := aFields[i].DataSet;
677 Inc(j);
678 end;
679 SetLength(FParams,j);
680 end;
681
682 destructor TParamListIntf.Destroy;
683 begin
684 SetLength(FParams,0);
685 inherited Destroy;
686 end;
687
688 function TParamListIntf.getCount: integer;
689 begin
690 Result := Length(FParams);
691 end;
692
693 function TParamListIntf.getSQLParam(index: integer): ISQLParam;
694 begin
695 if (index < 0) or (index >= getCount) then
696 IBError(ibxeInvalidColumnIndex,[nil]);
697 Result := TParamIntf.Create(self,index);
698 end;
699
700 function TParamListIntf.ByName(Idx: AnsiString): ISQLParam;
701 var i: integer;
702 begin
703 Result := nil;
704 for i := 0 to getCount - 1 do
705 if CompareText(FParams[i].Name,Idx) = 0 then
706 begin
707 Result := getSQLParam(i);
708 Exit;
709 end;
710 end;
711
712 function TParamListIntf.GetModified: Boolean;
713 begin
714 Result := FModified;
715 end;
716
717 function TParamListIntf.GetHasCaseSensitiveParams: Boolean;
718 begin
719 Result := false;
720 end;
721
722 { TIBUpdate }
723
724 function TIBUpdate.GetSQL(UpdateKind: TUpdateKind): TStrings;
725 begin
726 Result := FDummySQL; {non empty result}
727 end;
728
729 function TIBUpdate.GetDataSet: TIBCustomDataSet;
730 begin
731 Result := FDataSet;
732 end;
733
734 procedure TIBUpdate.SetDataSet(ADataSet: TIBCustomDataSet);
735 begin
736 FDataSet := ADataset;
737 end;
738
739 procedure TIBUpdate.Apply(UpdateKind: TUpdateKind; buff: PChar);
740 var Params: ISQLParams;
741 begin
742 Params := TParamListIntf.Create(Dataset.Fields,(DataSet.Database as TIBDatabase));
743 InternalSetParams(Params,buff);
744 if assigned(FOnApplyUpdates) then
745 OnApplyUpdates(self,UpdateKind,Params);
746 end;
747
748 constructor TIBUpdate.Create(AOwner: TComponent);
749 begin
750 inherited Create(AOwner);
751 FDummySQL := TStringList.Create;
752 FDummySQL.Text := '*';
753 end;
754
755 destructor TIBUpdate.Destroy;
756 begin
757 if assigned(FDummySQL) then FDummySQL.Free;
758 inherited Destroy;
759 end;
760
761 end.
762