Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Midas/TClientDataSet    [ Add a report in this area ]  
Report #:  3786   Status: Closed
ClientDataSet.FindKey on cloned cursor fails
Project:  Delphi Build #:  4.453
Version:    7.0 Submitted By:   Mathias Burbach
Report Type:  Basic functionality failure Date Reported:  3/12/2003 4:46:42 PM
Severity:    Serious / Highly visible problem Last Updated: 6/27/2006 12:27:41 PM
Platform:    95, 98, 2000, NT, XP Internal Tracking #:   158140
Resolution: Fixed (Resolution Comments) Resolved in Build: : 7.0.8.1
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: None
Description
I am using a ClientDataSet to retrieve data for a
Project
  with multiple Versions
    and an Item Tree (fishhook FK) for each Version

In a method I want to be able to copy a source version into a new target version including its item tree. The PK columns get negative values.

When I clone the cursor on the deepest level of nested dataset (Item Tree) and call FindKey the TCustomClientDataSet.GetIndexField function raises an exception because FIndexFieldMap[Index] returns a non-existing field number (list index out of bounds).
-----
[Dave Rowntree:
When CDS.CloneCursor(CDS, False) is cloning against a nested DataSet, the cloned active index does not appear to be created correctly. An additional instance of the LINK_FIELD appears to have been added to the front of the clone index.]
Steps to Reproduce:
1. Open project CopyNestedDS.dpr
2. Run the "application"
3. Click button "Copy Version"
4. Click button "Find Key"
5. Exception occurs
Workarounds
[Dave Rowntree:
When cloning a nested CDS DataSet, the active index can be created incorrectly. To correct the problem, redefine the active index on the clone directly after cloning. For example:

  cdsClone.CloneCursor( cdsMain, False);
  cdsClone.IndexFieldNames := '';
  cdsClone.IndexFieldNames := TClientDataSet(cdsClone.CloneSource).IndexFieldNames;
]

---------

When cloning a nested CDS DataSet, the active index can be created incorrectly. To correct the problem, redefine the active index on the clone directly after cloning. For example:

  cdsClone.CloneCursor( cdsMain, False);
  cdsClone.IndexFieldNames := '';
  cdsClone.IndexFieldNames := TClientDataSet(cdsClone.CloneSource).IndexFieldNames;
Attachment
CopyNestedDS.zip
Comments

Dave Rowntree at 5/11/2004 3:46:24 AM -
Fixed in Midas.dll and dbclient.pas

Server Response from: CODE1