Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004660 [JEDI VCL] 00 JVCL Components crash always 2009-01-13 07:35 2009-10-03 17:51
Reporter ALDettmer View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version 3.33
Summary 0004660: JvDBSpinEdit has problems with TFMTBCDFields
Description I'm working, in DELPHI 2007, with JEDI JvDBSpinEdit connected to an ORACLE 10 database using dbExpress technology. The table definition (a sample of all fields) can be seen below:

create FMTBCDProblems (
  VLKM NUMBER (10,3),
  NULONG NUMBER (15,8),
  NULAN NUMBER(15,8)
)

Working with tables with fields defined like the example above, I found two problems as follows:

A) When I try to modify, using TJvDBSpinEdit components, columns defined like the example above the component raise EVariantInvalidOpError exceptions with the message "Invalid variant operation." when I change focus from the TJvDBSpinEdit instance to another component. After some investigation I found that the "offending" line of code was into the method that follow, at the line below the comment:

procedure TJvDBSpinEdit.SetValue(NewValue: Extended);
begin
  if FDataLink.CanModify then
  begin
    FIsNull := (Text = '') and (NewValue = 0.0);
    if not (FIsNull and FAllowNull) then
      inherited SetValue(NewValue);
    if not FDataChanging and (FDataLink.Field <> nil) then
    begin
      if (IsNull and not FDataLink.Field.IsNull) or
// THE LINE BELOW RISE THE EXCEPTION
         (not IsNull and FDataLink.Field.Value <> NewValue) then
        FDataLink.Edit;
    end;
  end;
end;

To my surprise FDataLink.Field.Value returned a string instead of a float value. Since NewValue is, always, a number I modified the method above to this:

procedure TJvDBSpinEdit.SetValue(NewValue: Extended);
begin
  if FDataLink.CanModify then
  begin
    FIsNull := (Text = '') and (NewValue = 0.0);
    if not (FIsNull and FAllowNull) then
      inherited SetValue(NewValue);
    if not FDataChanging and (FDataLink.Field <> nil) then
    begin
      if (IsNull and not FDataLink.Field.IsNull) or
// THE LINE BELOW RISE THE EXCEPTION
// (not IsNull and FDataLink.Field.Value <> NewValue) then
// THE LINE BELOW IS MINE BUG FIX PROPOSITION
        (not IsNull and (FDataLink.Field.asFloat <> NewValue)) then
        FDataLink.Edit;
    end;
  end;
end;

NOTE: I just checked this against dbExpress databases, not ADO neither BDE.

B) After solving this problem I tried to use the THOUSANDS property to format the values. The format worked very well but, again, when a changed the focus away from the TJvDBSpinEdit components an exception raised, a distinct one this time. This second exception is of type EBcdException with the message "350.175 is not a valid BCD value.". Here 350175 is the value currently stored in my data base and the DOT is the thousand separator here in Brazil. After a little investigation I found the error source:

procedure TJvDBSpinEdit.UpdateData(Sender: TObject);
begin
  { Never masked? }
  {ValidateEdit;}
  if FDataLink.Editing then
// THE LINE BELOW RISE THE EXCEPTION
    FDataLink.Field.Text := Text;
end;

Since I know that there are a GetValue function available I changed the method above to what you can see below:

procedure TJvDBSpinEdit.UpdateData(Sender: TObject);
begin
  { Never masked? }
  {ValidateEdit;}
  if FDataLink.Editing then
// THE LINE BELOW RISE THE EXCEPTION
// FDataLink.Field.Text := Text;
// THE LINE BELOW IS MINE BUG FIX PROPOSITION
    FDataLink.Field.Text := FloatToStr(getValue);
end;

NOTE: Again I tested this bug fix only against dbExpress technology but AFAIK the fix should work for other database connection technologies.

I hope that this can help you to improve a little bit this component and the JEDI suite as a whole. Please fell free to mail me.

Regards,

Armando
Additional Information
Tags No tags attached.
Attached Files zip file icon DB Spin Edit BUG Sample.zip [^] (36,723 bytes) 2009-07-09 22:48

- Relationships

-  Notes
(0015446)
obones (administrator)
2009-04-29 11:43

Please provide the zipped sources of a sample standalone application showing this
(0015824)
obones (administrator)
2009-07-09 17:12

Any news?
(0015840)
ALDettmer (reporter)
2009-07-09 22:50

Hi obones, I added a sample to check the problem. See added file, it contains a delphi 2007 dbExpress project and a SQL file that create a oracle table and insert sample data into it.
(0015923)
obones (administrator)
2009-08-05 11:13

Someone with an oracle server will have to try this
(0016234)
AHUser (developer)
2009-10-03 17:51

Fixed in SVN.

- Issue History
Date Modified Username Field Change
2009-01-13 07:35 ALDettmer New Issue
2009-02-02 01:21 obones Status new => acknowledged
2009-04-29 11:43 obones Note Added: 0015446
2009-04-29 11:43 obones Status acknowledged => feedback
2009-07-09 17:12 obones Note Added: 0015824
2009-07-09 22:48 ALDettmer File Added: DB Spin Edit BUG Sample.zip
2009-07-09 22:50 ALDettmer Note Added: 0015840
2009-08-05 11:13 obones Note Added: 0015923
2009-08-05 11:13 obones Status feedback => acknowledged
2009-10-03 17:51 AHUser Note Added: 0016234
2009-10-03 17:51 AHUser Status acknowledged => resolved
2009-10-03 17:51 AHUser Fixed in Version => Daily / SVN
2009-10-03 17:51 AHUser Resolution open => fixed
2009-10-03 17:51 AHUser Assigned To => AHUser


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker