Board index » delphi » Bug? TADOQuery FieldValues['SomeDoublePrecisionValue'] returns Integer

Bug? TADOQuery FieldValues['SomeDoublePrecisionValue'] returns Integer

2004-06-12 05:50:42 AM
I have encountered some unexpected behavior with Delphi 7 Pro and Delphi 7 Pro with the
7.1 update that I'd like help understanding.
Invoices: TADOQuery;
CreditAmountNeeded: Currency;
{Invoices is a parameterized query on a customer ID field:string}
with Invoices do begin
// ShowMessageFmt('Just FieldValues:
%f',[FieldValues['AppliedAmount']]); // Exception - %f specifier not
supported for data type
// NB: error didn't show up in early testing because Min and Max
accepted an Integer type value without complaining!!!
ShowMessageFmt('With FieldValues: %f',[CreditAmountNeeded]); //
shows 133.00 <>the correct value
CreditAmountNeeded:=Max(0,FieldByName('AppliedAmount').AsCurrency -
ShowMessageFmt('With FieldByName: %f',[CreditAmountNeeded]); //
shows 133.33 = the correct value
Extracting the FieldValues['AppliedAmount'] (read from a Ms Access db on the
local machine - Win2k SP4) seems to
return the field value truncated to integer. Is this
reproducible/documented/intended behavior?
Some time ago I had some runtime errors reading DateTime fields using
FieldValues['fieldname'] that in hindsight must have been from
assigning integer values where TDateTime was expected.
Also, where is the bug reporting facility on the Borland site? (is there
How do you tell if the Delphi 7.1 update is installed properly (other than
accepting the word of the installation program)
Many Thanks in Advance, Dennis Reichel

Re:Bug? TADOQuery FieldValues['SomeDoublePrecisionValue'] returns Integer

"Brian Bushay TeamB">>Do you have persistent fields defined?
Yes, although I still perceived it to be more convenient using
FieldValues[fldName] to access those values.
My workaround in this case was to rewrite those statements retrieving a
non-(integer or string) - to use
the FieldByName(fldName).AsCurrency or FieldByName(fldName).AsDateTime
Here is an abbreviated object definition for that Query:
object Invoices: TADOQuery
Connection = QBFCModule.PerformanceCache
CursorType = ctStatic
BeforePost = UpdateCriteria
BeforeDelete = UpdateCriteria
Parameters = <
Name = 'P_ContractTxnID'
Attributes = [paNullable]
DataType = ftWideString
NumericScale = 255
Precision = 255
Size = 510
Value = Null
Prepared = True
SQL.Strings = (
'SELECT Invoice.*'
'FROM Invoice WHERE ContractTxnID=:P_ContractTxnID AND'
'ORDER BY BillingPeriod'
Left = 36
Top = 72
object InvoicesContractTxnID: TWideStringField
FieldName = 'ContractTxnID'
Size = 50
object InvoicesTxnDate: TDateTimeField
FieldName = 'TxnDate'
object InvoicesAppliedAmount: TBCDField
FieldName = 'AppliedAmount'
currency = True
Precision = 19
8>< snip><8

>How do you tell if the Delphi 7.1 update is installed properly (other
>accepting the word of the installation program)

Help|About| screen will show the version number.

Mutter... Grumble.. I'd have thought so, but it still shows v 7.0 Build
8.1. Looking further, I find that is correct.
The final dialog of the update installer indicates whether the
update was successful. You can also:
* Open Delphi 7 and use "Help | About" to display the About Box.
The product version should be:
Version 7.0 (Build 8.1)
(Before applying the update, the version is 7.0 (Build 4.453).)
* Use the file list in "FILES INSTALLED BY THIS UPDATE" below to
verify that the correct file versions are installed on your
Thanks for your information about Borland QualityCentral. I have obtained the
windows based client and searched for
related bug reports without any hits.
Regards, Dennis Reichel

Re:Bug? TADOQuery FieldValues['SomeDoublePrecisionValue'] returns Integer

Hi Brian
NB - the problem does not affect Currency fields in the msaccess
table - only double (apparently). Also, the Variant Type is NOT Integer - I
don't know WHAT it is. Integer just seems to be the best fit that
Delphi can manage when working with it as a Variant.
I sent you a zipped binary (including sample msaccess db) containing a
project to replicate the anomality. This list doesn't accept binaries and I
doubt it is worth posting it in text here since most of the convenience would
be derived through using the sample database.... Waiting for your findings.
If anyone else wants the test project, (it's about 20KB). please contact
me off list.. XXXX@XXXXX.COM
Test output:
Record ID: record 1
FieldString: Reference to a dynamically allocated UNICODE string
FieldDouble: Undefined Variant Type
FieldCurrency: Currency floating-point value (type Currency)
FieldDateTime: Date and time value (type TDateTime)
A diagnostic function:
function TForm1.VarTypeName(V:Variant):String;
case VarType(V) of
varCurrency:Result:='Currency floating-point value (type Currency)';
varDate: Result:='Date and time value (type TDateTime)';
varOleStr: Result:='Reference to a dynamically allocated UNICODE
varDispatch:Result:='Reference to an Automation object (an IDispatch
interface pointer)';
varError: Result:='Operating system error code';
varBoolean: Result:='16-bit boolean (type WordBool)';
varVariant: Result:='A variant';
varUnknown: Result:='Reference to an unknown object (an IInterface or
IUnknown interface pointer)';
varShortInt:Result:='8-bit signed integer (type ShortInt in Delphi or
signed char in C++)';
varByte: Result:='A Byte';
varWord: Result:='unsigned 16-bit value (Word)';
varLongWord:Result:='unsigned 32-bit value (type LongWord in Delphi or
unsigned long in C++)';
varInt64: Result:='64-bit signed integer (Int64 in Delphi or __int64
in C++)';
varStrArg: Result:='COM-compatible string';
varString: Result:='Reference to a dynamically allocated string (not COM
varAny: Result:='A CORBA Any value';
else Result:='Undefined Variant Type';
if V = Null then
Result:=Result + ' (V=Null)';
"Brian Bushay TeamB" <XXXX@XXXXX.COM>writes

>Yes, although I still perceived it to be more convenient using
>FieldValues[fldName] to access those values.
>My workaround in this case was to rewrite those statements retrieving a
>non-(integer or string) - to use
>the FieldByName(fldName).AsCurrency or FieldByName(fldName).AsDateTime

I have always considered it good coding practice to use the ASCurrency and
AS methods for extracting values from fields so I'd encourage you to
continue coding that way. However I have been trying to reproduce this
and have
not been able to. If you have any other PCs with Delphi installed that
you can
test this on it would be helpful to know more about the machines that show
as a problem.
I am using a Win 2K box with standard US currency formatting.

Brian Bushay (TeamB)