41 |
|
|
42 |
|
TIBUpdate = class(TIBDataSetUpdateObject) |
43 |
|
private |
44 |
– |
FDataSet: TIBCustomDataSet; |
44 |
|
FDummySQL: TStrings; |
45 |
|
FOnApplyUpdates: TOnApplyUpdates; |
46 |
|
protected |
47 |
|
function GetSQL(UpdateKind: TUpdateKind): TStrings; override; |
48 |
< |
function GetDataSet: TIBCustomDataSet; override; |
50 |
< |
procedure SetDataSet(ADataSet: TIBCustomDataSet); override; |
51 |
< |
procedure Apply(UpdateKind: TUpdateKind; buff: PChar); override; |
48 |
> |
procedure Apply(UpdateKind: TUpdateKind; buff: TRecordBuffer); override; |
49 |
|
public |
50 |
|
constructor Create(AOwner: TComponent); override; |
51 |
|
destructor Destroy; override; |
57 |
|
|
58 |
|
implementation |
59 |
|
|
60 |
< |
uses variants, FmtBCD, DateUtils; |
60 |
> |
uses variants, FmtBCD, DateUtils, FBNumeric; |
61 |
|
|
62 |
|
type |
63 |
|
|
86 |
|
{ISQLParams} |
87 |
|
function getCount: integer; |
88 |
|
function getSQLParam(index: integer): ISQLParam; |
89 |
+ |
function ParamExists(Idx: AnsiString): boolean; |
90 |
|
function ByName(Idx: AnsiString): ISQLParam ; |
91 |
|
function GetModified: Boolean; |
92 |
|
function GetHasCaseSensitiveParams: Boolean; |
93 |
+ |
function GetStatement: IStatement; |
94 |
+ |
function GetTransaction: ITransaction; |
95 |
+ |
function GetAttachment: IAttachment; |
96 |
+ |
procedure Clear; |
97 |
|
end; |
98 |
|
|
99 |
|
{ TParamIntf } |
139 |
|
function GetAsBlob: IBlob; |
140 |
|
function GetAsArray: IArray; |
141 |
|
function GetAsBCD: tBCD; |
142 |
+ |
function GetAsNumeric: IFBNumeric; |
143 |
|
function GetStatement: IStatement; |
144 |
|
function GetTransaction: ITransaction; |
145 |
+ |
function GetAttachment: IAttachment; |
146 |
|
procedure Clear; |
147 |
|
function GetModified: boolean; |
148 |
|
procedure SetAsBoolean(AValue: boolean); |
171 |
|
procedure SetAsQuad(aValue: TISC_QUAD); |
172 |
|
procedure SetCharSetID(aValue: cardinal); |
173 |
|
procedure SetAsBcd(aValue: tBCD); |
174 |
+ |
procedure SetAsNumeric(Value: IFBNumeric); |
175 |
|
end; |
176 |
|
|
177 |
|
{ TParamIntf } |
246 |
|
|
247 |
|
function TParamIntf.GetAsBoolean: boolean; |
248 |
|
begin |
249 |
< |
Result := FOwner.FParams[FIndex].Value; |
249 |
> |
if VarIsNull(FOwner.FParams[FIndex].Value) then |
250 |
> |
Result := false |
251 |
> |
else |
252 |
> |
Result := FOwner.FParams[FIndex].Value; |
253 |
|
end; |
254 |
|
|
255 |
|
function TParamIntf.GetAsCurrency: Currency; |
470 |
|
Result := VarToBCD(FOwner.FParams[FIndex].Value); |
471 |
|
end; |
472 |
|
|
473 |
+ |
function TParamIntf.GetAsNumeric: IFBNumeric; |
474 |
+ |
begin |
475 |
+ |
IBError(ibxeNotSupported,[]); |
476 |
+ |
end; |
477 |
+ |
|
478 |
|
function TParamIntf.GetStatement: IStatement; |
479 |
|
begin |
480 |
|
IBError(ibxeNotSupported,[]); |
485 |
|
IBError(ibxeNotSupported,[]); |
486 |
|
end; |
487 |
|
|
488 |
+ |
function TParamIntf.GetAttachment: IAttachment; |
489 |
+ |
begin |
490 |
+ |
IBError(ibxeNotSupported,[]); |
491 |
+ |
end; |
492 |
+ |
|
493 |
|
procedure TParamIntf.Clear; |
494 |
|
begin |
495 |
|
FOwner.SetParam(FIndex,NULL); |
656 |
|
FOwner.SetParam(FIndex,VarFmtBCDCreate(AValue)); |
657 |
|
end; |
658 |
|
|
659 |
+ |
procedure TParamIntf.SetAsNumeric(Value: IFBNumeric); |
660 |
+ |
begin |
661 |
+ |
IBError(ibxeNotSupported,[]); |
662 |
+ |
end; |
663 |
+ |
|
664 |
|
{ TParamListIntf } |
665 |
|
|
666 |
|
procedure TParamListIntf.SetParam(index: integer; aValue: variant); |
720 |
|
Result := TParamIntf.Create(self,index); |
721 |
|
end; |
722 |
|
|
723 |
+ |
function TParamListIntf.ParamExists(Idx: AnsiString): boolean; |
724 |
+ |
begin |
725 |
+ |
Result := ByName(Idx) <> nil; |
726 |
+ |
end; |
727 |
+ |
|
728 |
|
function TParamListIntf.ByName(Idx: AnsiString): ISQLParam; |
729 |
|
var i: integer; |
730 |
|
begin |
747 |
|
Result := false; |
748 |
|
end; |
749 |
|
|
750 |
< |
{ TIBUpdate } |
750 |
> |
function TParamListIntf.GetStatement: IStatement; |
751 |
> |
begin |
752 |
> |
IBError(ibxeNotSupported,[]); |
753 |
> |
end; |
754 |
|
|
755 |
< |
function TIBUpdate.GetSQL(UpdateKind: TUpdateKind): TStrings; |
755 |
> |
function TParamListIntf.GetTransaction: ITransaction; |
756 |
|
begin |
757 |
< |
Result := FDummySQL; {non empty result} |
757 |
> |
IBError(ibxeNotSupported,[]); |
758 |
|
end; |
759 |
|
|
760 |
< |
function TIBUpdate.GetDataSet: TIBCustomDataSet; |
760 |
> |
function TParamListIntf.GetAttachment: IAttachment; |
761 |
|
begin |
762 |
< |
Result := FDataSet; |
762 |
> |
Result := Database.Attachment; |
763 |
|
end; |
764 |
|
|
765 |
< |
procedure TIBUpdate.SetDataSet(ADataSet: TIBCustomDataSet); |
765 |
> |
procedure TParamListIntf.Clear; |
766 |
> |
var i: integer; |
767 |
|
begin |
768 |
< |
FDataSet := ADataset; |
768 |
> |
for i := 0 to getCount - 1 do |
769 |
> |
getSQLParam(i).Clear; |
770 |
> |
end; |
771 |
> |
|
772 |
> |
{ TIBUpdate } |
773 |
> |
|
774 |
> |
function TIBUpdate.GetSQL(UpdateKind: TUpdateKind): TStrings; |
775 |
> |
begin |
776 |
> |
Result := FDummySQL; {non empty result} |
777 |
|
end; |
778 |
|
|
779 |
< |
procedure TIBUpdate.Apply(UpdateKind: TUpdateKind; buff: PChar); |
779 |
> |
procedure TIBUpdate.Apply(UpdateKind: TUpdateKind; buff: TRecordBuffer); |
780 |
|
var Params: ISQLParams; |
781 |
|
begin |
782 |
|
Params := TParamListIntf.Create(Dataset.Fields,(DataSet.Database as TIBDatabase)); |