Subject | A bug in procedure TIB_Statement.SysRestoreParamValueLinks |
---|---|
Author | Calin Iancu Pirtea |
Post date | 2003-08-21T05:41:32Z |
The bug is related to datetime fields.
When params are backed up datetime params are saved as a string
with the format 'yyyy/mm/dd hh:nn:ss'
When they are restored this happens:
if IsDateTime and ( tmpStr <> '' ) then
AsDateTime := EncodeStringToDateTime( tmpStr )
else
if IsCurrencyDataType then
tmpStr[Length(tmpStr)+SQLScale]:=DecimalSeparator;
AsString := tmpStr;
If the param is DateTime the old datetime is correctly assigned using:
AsDateTime := EncodeStringToDateTime( tmpStr )
but after succesfully asigning it, another attempt is made to assign the
wrong value found in tmpStr as a DateTime with:
AsString := tmpStr;
If someone is lucky their system will have the date format yyyy/mm/dd so
it will work but if they have a different format...
The fix is very simple:
if IsDateTime and ( tmpStr <> '' ) then
AsDateTime := EncodeStringToDateTime( tmpStr )
else
begin
if IsCurrencyDataType then
tmpStr[Length(tmpStr)+SQLScale]:=DecimalSeparator;
AsString := tmpStr;
end;
Ciao,
Best regards,
Application Developer
Calin Iancu, Pirtea
S.C. SoftScape S.R.L.
pcalin@...
When params are backed up datetime params are saved as a string
with the format 'yyyy/mm/dd hh:nn:ss'
When they are restored this happens:
if IsDateTime and ( tmpStr <> '' ) then
AsDateTime := EncodeStringToDateTime( tmpStr )
else
if IsCurrencyDataType then
tmpStr[Length(tmpStr)+SQLScale]:=DecimalSeparator;
AsString := tmpStr;
If the param is DateTime the old datetime is correctly assigned using:
AsDateTime := EncodeStringToDateTime( tmpStr )
but after succesfully asigning it, another attempt is made to assign the
wrong value found in tmpStr as a DateTime with:
AsString := tmpStr;
If someone is lucky their system will have the date format yyyy/mm/dd so
it will work but if they have a different format...
The fix is very simple:
if IsDateTime and ( tmpStr <> '' ) then
AsDateTime := EncodeStringToDateTime( tmpStr )
else
begin
if IsCurrencyDataType then
tmpStr[Length(tmpStr)+SQLScale]:=DecimalSeparator;
AsString := tmpStr;
end;
Ciao,
Best regards,
Application Developer
Calin Iancu, Pirtea
S.C. SoftScape S.R.L.
pcalin@...