View Issue Details

IDProjectCategoryView StatusLast Update
0004660JEDI VCL00 JVCL Componentspublic2009-10-03 17:51
ReporterALDettmerAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.33 
Target VersionFixed in Version3.39 
Summary0004660: JvDBSpinEdit has problems with TFMTBCDFields
DescriptionI'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
TagsNo tags attached.

Activities

obones

2009-04-29 11:43

administrator   ~0015446

Please provide the zipped sources of a sample standalone application showing this

obones

2009-07-09 17:12

administrator   ~0015824

Any news?

2009-07-09 22:48

 

DB Spin Edit BUG Sample.zip (36,723 bytes)

ALDettmer

2009-07-09 22:50

reporter   ~0015840

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.

obones

2009-08-05 11:13

administrator   ~0015923

Someone with an oracle server will have to try this

AHUser

2009-10-03 17:51

developer   ~0016234

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