mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-11 07:50:43 +01:00
* Added ftFmtBCD param support, from Ladislav Karrach, bug #18809
git-svn-id: trunk@17425 -
This commit is contained in:
parent
0e56e188f8
commit
2ad62c4754
@ -1130,6 +1130,7 @@ type
|
|||||||
Function GetAsMemo: string;
|
Function GetAsMemo: string;
|
||||||
Function GetAsString: string;
|
Function GetAsString: string;
|
||||||
Function GetAsVariant: Variant;
|
Function GetAsVariant: Variant;
|
||||||
|
Function GetAsFMTBCD: TBCD;
|
||||||
Function GetDisplayName: string; override;
|
Function GetDisplayName: string; override;
|
||||||
Function GetIsNull: Boolean;
|
Function GetIsNull: Boolean;
|
||||||
Function IsEqual(AValue: TParam): Boolean;
|
Function IsEqual(AValue: TParam): Boolean;
|
||||||
@ -1147,6 +1148,7 @@ type
|
|||||||
Procedure SetAsTime(const AValue: TDateTime);
|
Procedure SetAsTime(const AValue: TDateTime);
|
||||||
Procedure SetAsVariant(const AValue: Variant);
|
Procedure SetAsVariant(const AValue: Variant);
|
||||||
Procedure SetAsWord(AValue: LongInt);
|
Procedure SetAsWord(AValue: LongInt);
|
||||||
|
Procedure SetAsFMTBCD(const AValue: TBCD);
|
||||||
Procedure SetDataType(AValue: TFieldType);
|
Procedure SetDataType(AValue: TFieldType);
|
||||||
Procedure SetText(const AValue: string);
|
Procedure SetText(const AValue: string);
|
||||||
function GetAsWideString: WideString;
|
function GetAsWideString: WideString;
|
||||||
@ -1179,6 +1181,7 @@ type
|
|||||||
Property AsString : string read GetAsString write SetAsString;
|
Property AsString : string read GetAsString write SetAsString;
|
||||||
Property AsTime : TDateTime read GetAsDateTime write SetAsTime;
|
Property AsTime : TDateTime read GetAsDateTime write SetAsTime;
|
||||||
Property AsWord : LongInt read GetAsInteger write SetAsWord;
|
Property AsWord : LongInt read GetAsInteger write SetAsWord;
|
||||||
|
Property AsFMTBCD: TBCD read GetAsFMTBCD write SetAsFMTBCD;
|
||||||
Property Bound : Boolean read FBound write FBound;
|
Property Bound : Boolean read FBound write FBound;
|
||||||
Property Dataset : TDataset Read GetDataset;
|
Property Dataset : TDataset Read GetDataset;
|
||||||
Property IsNull : Boolean read GetIsNull;
|
Property IsNull : Boolean read GetIsNull;
|
||||||
|
|||||||
@ -569,6 +569,14 @@ begin
|
|||||||
Result:=FValue;
|
Result:=FValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TParam.GetAsFMTBCD: TBCD;
|
||||||
|
begin
|
||||||
|
If IsNull then
|
||||||
|
Result:=0
|
||||||
|
else
|
||||||
|
Result:=VarToBCD(FValue);
|
||||||
|
end;
|
||||||
|
|
||||||
Function TParam.GetDisplayName: string;
|
Function TParam.GetDisplayName: string;
|
||||||
begin
|
begin
|
||||||
if (FName<>'') then
|
if (FName<>'') then
|
||||||
@ -697,7 +705,10 @@ begin
|
|||||||
FDataType:=ftString;
|
FDataType:=ftString;
|
||||||
varInt64 : FDataType:=ftLargeInt;
|
varInt64 : FDataType:=ftLargeInt;
|
||||||
else
|
else
|
||||||
FDataType:=ftUnknown;
|
if VarIsFmtBCD(Value) then
|
||||||
|
FDataType:=ftFmtBCD
|
||||||
|
else
|
||||||
|
FDataType:=ftUnknown;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -707,6 +718,11 @@ begin
|
|||||||
FDataType:=ftWord;
|
FDataType:=ftWord;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TParam.SetAsFMTBCD(const AValue: TBCD);
|
||||||
|
begin
|
||||||
|
FValue:=VarFmtBCDCreate(AValue);
|
||||||
|
FDataType:=ftFMTBcd;
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TParam.SetDataType(AValue: TFieldType);
|
Procedure TParam.SetDataType(AValue: TFieldType);
|
||||||
|
|
||||||
@ -804,6 +820,7 @@ begin
|
|||||||
ftDateTime : Field.AsDateTime:=AsDateTime;
|
ftDateTime : Field.AsDateTime:=AsDateTime;
|
||||||
ftBytes,
|
ftBytes,
|
||||||
ftVarBytes : ; // Todo.
|
ftVarBytes : ; // Todo.
|
||||||
|
ftFmtBCD : Field.AsBCD:=AsFMTBCD;
|
||||||
else
|
else
|
||||||
If not (DataType in [ftCursor, ftArray, ftDataset,ftReference]) then
|
If not (DataType in [ftCursor, ftArray, ftDataset,ftReference]) then
|
||||||
DatabaseErrorFmt(SBadParamFieldType, [Name], DataSet);
|
DatabaseErrorFmt(SBadParamFieldType, [Name], DataSet);
|
||||||
@ -841,6 +858,7 @@ begin
|
|||||||
ftDateTime : AsDateTime:=Field.AsDateTime;
|
ftDateTime : AsDateTime:=Field.AsDateTime;
|
||||||
ftBytes,
|
ftBytes,
|
||||||
ftVarBytes : ; // Todo.
|
ftVarBytes : ; // Todo.
|
||||||
|
ftFmtBCD : AsFMTBCD:=Field.AsBCD;
|
||||||
else
|
else
|
||||||
If not (DataType in [ftCursor, ftArray, ftDataset,ftReference]) then
|
If not (DataType in [ftCursor, ftArray, ftDataset,ftReference]) then
|
||||||
DatabaseErrorFmt(SBadParamFieldType, [Name], DataSet);
|
DatabaseErrorFmt(SBadParamFieldType, [Name], DataSet);
|
||||||
@ -938,6 +956,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
ftFmtBCD : PBCD(Buffer)^:=AsFMTBCD;
|
||||||
else
|
else
|
||||||
If not (DataType in [ftCursor, ftArray, ftDataset,ftReference]) then
|
If not (DataType in [ftCursor, ftArray, ftDataset,ftReference]) then
|
||||||
DatabaseErrorFmt(SBadParamFieldType, [Name], DataSet);
|
DatabaseErrorFmt(SBadParamFieldType, [Name], DataSet);
|
||||||
@ -976,6 +995,7 @@ begin
|
|||||||
ftDataSet,
|
ftDataSet,
|
||||||
ftReference,
|
ftReference,
|
||||||
ftCursor : Result:=0;
|
ftCursor : Result:=0;
|
||||||
|
ftFmtBCD : Result:=SizeOf(TBCD);
|
||||||
else
|
else
|
||||||
DatabaseErrorFmt(SBadParamFieldType,[Name],DataSet);
|
DatabaseErrorFmt(SBadParamFieldType,[Name],DataSet);
|
||||||
end;
|
end;
|
||||||
@ -1057,6 +1077,7 @@ begin
|
|||||||
ftGraphic..ftTypedBinary,
|
ftGraphic..ftTypedBinary,
|
||||||
ftOraBlob,
|
ftOraBlob,
|
||||||
ftOraClob : SetBlobData(Buffer, StrLen(PChar(Buffer)));
|
ftOraClob : SetBlobData(Buffer, StrLen(PChar(Buffer)));
|
||||||
|
ftFmtBCD : AsFMTBCD:=PBCD(Buffer)^;
|
||||||
else
|
else
|
||||||
DatabaseErrorFmt(SBadParamFieldType,[Name],DataSet);
|
DatabaseErrorFmt(SBadParamFieldType,[Name],DataSet);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -181,6 +181,7 @@ begin
|
|||||||
do1:= P.asfloat;
|
do1:= P.asfloat;
|
||||||
checkerror(sqlite3_bind_double(fstatement,I,do1));
|
checkerror(sqlite3_bind_double(fstatement,I,do1));
|
||||||
end;
|
end;
|
||||||
|
ftFMTBcd,
|
||||||
ftstring,
|
ftstring,
|
||||||
ftmemo: begin // According to SQLite documentation, CLOB's (ftMemo) have the Text affinity
|
ftmemo: begin // According to SQLite documentation, CLOB's (ftMemo) have the Text affinity
|
||||||
str1:= p.asstring;
|
str1:= p.asstring;
|
||||||
|
|||||||
@ -88,6 +88,7 @@ type
|
|||||||
procedure TestDateParamQuery;
|
procedure TestDateParamQuery;
|
||||||
procedure TestIntParamQuery;
|
procedure TestIntParamQuery;
|
||||||
procedure TestTimeParamQuery;
|
procedure TestTimeParamQuery;
|
||||||
|
procedure TestFmtBCDParamQuery;
|
||||||
procedure TestFloatParamQuery;
|
procedure TestFloatParamQuery;
|
||||||
procedure TestBCDParamQuery;
|
procedure TestBCDParamQuery;
|
||||||
procedure TestAggregates;
|
procedure TestAggregates;
|
||||||
@ -109,7 +110,7 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses sqldbtoolsunit,toolsunit, variants, sqldb, bufdataset, strutils, dbconst;
|
uses sqldbtoolsunit,toolsunit, variants, sqldb, bufdataset, strutils, dbconst, FmtBCD;
|
||||||
|
|
||||||
Type HackedDataset = class(TDataset);
|
Type HackedDataset = class(TDataset);
|
||||||
|
|
||||||
@ -729,6 +730,11 @@ begin
|
|||||||
TestXXParamQuery(ftInteger,'INT',testIntValuesCount);
|
TestXXParamQuery(ftInteger,'INT',testIntValuesCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestFieldTypes.TestFmtBCDParamQuery;
|
||||||
|
begin
|
||||||
|
TestXXParamQuery(ftFMTBcd,FieldtypeDefinitionsConst[ftFMTBcd],testValuesCount);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestFieldTypes.TestTimeParamQuery;
|
procedure TTestFieldTypes.TestTimeParamQuery;
|
||||||
begin
|
begin
|
||||||
TestXXParamQuery(ftTime,FieldtypeDefinitionsConst[ftTime],testValuesCount);
|
TestXXParamQuery(ftTime,FieldtypeDefinitionsConst[ftTime],testValuesCount);
|
||||||
@ -797,6 +803,7 @@ begin
|
|||||||
Params.ParamByName('field1').AsString:= testDateValues[i]
|
Params.ParamByName('field1').AsString:= testDateValues[i]
|
||||||
else
|
else
|
||||||
Params.ParamByName('field1').AsDateTime:= StrToDate(testDateValues[i],'yyyy/mm/dd','-');
|
Params.ParamByName('field1').AsDateTime:= StrToDate(testDateValues[i],'yyyy/mm/dd','-');
|
||||||
|
ftFMTBcd : Params.ParamByName('field1').AsFMTBCD:= StrToBCD(testFmtBCDValues[i]{,DBConnector.FormatSettings})
|
||||||
else
|
else
|
||||||
AssertTrue('no test for paramtype available',False);
|
AssertTrue('no test for paramtype available',False);
|
||||||
end;
|
end;
|
||||||
@ -819,6 +826,7 @@ begin
|
|||||||
ftString : AssertEquals(testStringValues[i],FieldByName('FIELD1').AsString);
|
ftString : AssertEquals(testStringValues[i],FieldByName('FIELD1').AsString);
|
||||||
ftTime : AssertEquals(testTimeValues[i],DateTimeToTimeString(FieldByName('FIELD1').AsDateTime));
|
ftTime : AssertEquals(testTimeValues[i],DateTimeToTimeString(FieldByName('FIELD1').AsDateTime));
|
||||||
ftdate : AssertEquals(testDateValues[i],FormatDateTime('yyyy/mm/dd',FieldByName('FIELD1').AsDateTime, DBConnector.FormatSettings));
|
ftdate : AssertEquals(testDateValues[i],FormatDateTime('yyyy/mm/dd',FieldByName('FIELD1').AsDateTime, DBConnector.FormatSettings));
|
||||||
|
ftFMTBcd : AssertEquals(testFmtBCDValues[i],BCDToStr(FieldByName('FIELD1').AsBCD{,DBConnector.FormatSettings}))
|
||||||
else
|
else
|
||||||
AssertTrue('no test for paramtype available',False);
|
AssertTrue('no test for paramtype available',False);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user