Mega Search
23.2 Million


Sign Up

Make a donation  
NestedDataSet (DataSetField) serious error occurred when poP  
News Group: embarcadero.public.delphi.database.multi-tier

NestedDataSet sequence error occurred. not bound to MasterDataSet?

Origin Data
Master Detail
03
      D03  D03_01_MOD
      D03  D03_02

04
      D04  D04_01


After ApplyUpdates, I got this

03
     D03  D03_01_MOD
     D04  D04_01  ****

04
     D03  D03_02  ****



MainFM.pas
{code}
unit MainFM;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids, Vcl.DBGrids,
  Data.DB, Datasnap.Provider, Datasnap.DBClient;

type
  TForm1 = class(TForm)
    cds00: TClientDataSet;
    qry00: TClientDataSet;
    dsp00: TDataSetProvider;
    qry00ID: TStringField;
    qry10: TClientDataSet;
    StringField1: TStringField;
    StringField2: TStringField;
    srcq10: TDataSource;
    cds10: TClientDataSet;
    cds00ID: TStringField;
    cds00qry10: TDataSetField;
    src00: TDataSource;
    src10: TDataSource;
    DBGrid1: TDBGrid;
    DBGrid2: TDBGrid;
    btnMakeData: TButton;
    cds10ID: TStringField;
    cds10V1: TStringField;
    btnApplyUpdates: TButton;
    qry10V2: TStringField;
    cds10V2: TStringField;
    procedure dsp00BeforeUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
      UpdateKind: TUpdateKind; var Applied: Boolean);
    procedure btnMakeDataClick(Sender: TObject);
    procedure btnApplyUpdatesClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnApplyUpdatesClick(Sender: TObject);
begin
  cds00.ApplyUpdates(0);
  {
  Master Detail
  03     ID   V1
         D03  V01_MOD
         D04  D04_01  ****
  04
         D03  D03_02  ****
  }
end;

procedure TForm1.btnMakeDataClick(Sender: TObject);
begin
  // step1<
  cds00.EmptyDataSet;

  cds00.Append;
  cds00ID.Value := '01';
  cds00.Post;

  cds10.Append;
  cds10ID.Value := 'D01';
  cds10.Post;

  cds00.Append;
  cds00ID.Value := '02';
  cds00.Post;

  cds10.Append;
  cds10ID.Value := 'D02';
  cds10.Post;

  cds00.Append;
  cds00ID.Value := '03';
  cds00.Post;

  cds10.Append;
  cds10ID.Value := 'D03';
  cds10V1.Value := 'D03_01';
  cds10.Post;

  cds00.ApplyUpdates(0);
  // step1>

  // Step2<
  cds00.RecNo := 3;
  cds10.Append;
  cds10ID.Value := 'D03';
  cds10V1.Value := 'D03_02';
  cds10.Post;

  cds00.Append;
  cds00ID.Value := '04';
  cds00.Post;

  cds10.Append;
  cds10ID.Value := 'D04';
  cds10V1.Value := 'D04_01';
  cds10.Post;

  // Error testing<
  cds00.RecNo := 3;
  cds10.RecNo := 1;
  cds10.Edit;
  cds10V1.Value := 'D03_01_MOD';
  cds10.Post;
  // Error testing>

  {
  Origin Data
  Master Detail
  03     ID     V1
         D03    D03_01_MOD
         D03    D03_02
  04
         D04    D04_01
  }
  // Step2>
end;

procedure TForm1.dsp00BeforeUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
  UpdateKind: TUpdateKind; var Applied: Boolean);
var
  Value: string;
begin
  Applied := True; // Not need update to DataBase

  if SourceDS = qry10 then
  begin
    Value := DeltaDS.FieldByName('ID').NewValue;
    if Value = '' then
      Value := DeltaDS.FieldByName('ID').OldValue;

    DeltaDS.FieldByName('V2').NewValue := 'DSP_' + Value;
  end;
end;

end.
{code}

MainFM.dfm
{code}
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 318
  ClientWidth = 659
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object DBGrid1: TDBGrid
    Left = 8
    Top = 8
    Width = 401
    Height = 120
    DataSource = src00
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'Tahoma'
    TitleFont.Style = []
  end
  object DBGrid2: TDBGrid
    Left = 8
    Top = 134
    Width = 401
    Height = 120
    DataSource = src10
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'Tahoma'
    TitleFont.Style = []
  end
  object btnMakeData: TButton
    Left = 8
    Top = 272
    Width = 75
    Height = 25
    Caption = 'MakeData'
    TabOrder = 2
    OnClick = btnMakeDataClick
  end
  object btnApplyUpdates: TButton
    Left = 106
    Top = 272
    Width = 103
    Height = 25
    Caption = 'ApplyUpdates'
    TabOrder = 3
    OnClick = btnApplyUpdatesClick
  end
  object cds00: TClientDataSet
    Active = True
    Aggregates = <>
    Params = <>
    ProviderName = 'dsp00'
    Left = 496
    Top = 16
    object cds00ID: TStringField
      FieldName = 'ID'
    end
    object cds00qry10: TDataSetField
      FieldName = 'qry10'
    end
  end
  object qry00: TClientDataSet
    Active = True
    Aggregates = <>
    FieldDefs = <
      item
        Name = 'ID'
        DataType = ftString
        Size = 20
      end>
    IndexDefs = <
      item
        Name = 'DEFAULT_ORDER'
      end
      item
        Name = 'CHANGEINDEX'
      end>
    Params = <>
    StoreDefs = True
    Left = 608
    Top = 16
    Data = {
      470000009619E0BD010000001800000001000000000003000000470002494401
      0049000000010005574944544802000200140001000D44454641554C545F4F52
      4445520200820000000000}
    object qry00ID: TStringField
      FieldName = 'ID'
    end
  end
  object dsp00: TDataSetProvider
    DataSet = qry00
    Options = [poPropogateChanges, poUseQuoteChar]
    BeforeUpdateRecord = dsp00BeforeUpdateRecord
    Left = 552
    Top = 16
  end
  object qry10: TClientDataSet
    Active = True
    Aggregates = <>
    FieldDefs = <
      item
        Name = 'ID'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'V1'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'V2'
        DataType = ftString
        Size = 20
      end>
    IndexDefs = <
      item
        Name = 'DEFAULT_ORDER'
      end
      item
        Name = 'CHANGEINDEX'
      end>
    IndexFieldNames = 'ID'
    MasterFields = 'ID'
    MasterSource = srcq10
    PacketRecords = 0
    Params = <>
    StoreDefs = True
    Left = 608
    Top = 128
    Data = {
      750000009619E0BD010000001800000003000000000003000000750002494401
      0049000000010005574944544802000200140002563101004900000001000557
      4944544802000200140002563201004900000001000557494454480200020014
      0001000D44454641554C545F4F524445520200820000000000}
    object StringField1: TStringField
      FieldName = 'ID'
    end
    object StringField2: TStringField
      FieldName = 'V1'
    end
    object qry10V2: TStringField
      FieldName = 'V2'
    end
  end
  object srcq10: TDataSource
    DataSet = qry00
    Left = 608
    Top = 72
  end
  object cds10: TClientDataSet
    Active = True
    Aggregates = <>
    DataSetField = cds00qry10
    Params = <>
    Left = 496
    Top = 72
    object cds10ID: TStringField
      FieldName = 'ID'
    end
    object cds10V1: TStringField
      FieldName = 'V1'
    end
    object cds10V2: TStringField
      FieldName = 'V2'
    end
  end
  object src00: TDataSource
    DataSet = cds00
    Left = 440
    Top = 16
  end
  object src10: TDataSource
    DataSet = cds10
    Left = 440
    Top = 72
  end
end
{code}


{code}
program Project1;

uses
  Vcl.Forms,
  MainFM in 'MainFM.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
{code}

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 10-Sep-2014, at 7:17 PM EST
From: jackie chang
 
Re: NestedDataSet (DataSetField) serious error occurred when  
News Group: embarcadero.public.delphi.database.multi-tier
It's seems MIDAS bug. This issue happen in XE4 / XE5 / XE7.
My english is poor, Would you like to help me reports to QC.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 11-Sep-2014, at 8:04 PM EST
From: jackie chang