Delphi (BCDField) Oracle FireDac Master Detail Raises Invalid variant type or size for field

410 views Asked by At

here my oracle table

CREATE TABLE TMASTER (
    ID NUMBER(10,0) NOT NULL,  -- DELPHI BCD with precision 10 sz 0
    PARENT NUMBER(10,0) NOT NULL,  -- DELPHI BCD with precision 10 sz 0
    NAME VARCHAR2(100) NOT NULL
);
CREATE UNIQUE INDEX TMASTER_ID ON TMASTER(ID);
ALTER TABLE TMASTER ADD CONSTRAINT TMASTER_ID PRIMARY KEY(ID);

CREATE TABLE TDETAIL (
    ID RAW(16) DEFAULT SYS_GUID() NOT NULL,
    MASTERID NUMBER(10,0),    -- DELPHI BCD with precision 10 sz 0
    SORTID NUMBER(10,0),  -- DELPHI BCD with precision 10 sz 0
    NAME VARCHAR2(100),
    QTY NUMBER(5,0), -- DELPHI BCD with precision 5 sz 0
    FOREIGN KEY (MASTERID) REFERENCES TMASTER(ID)
);
CREATE UNIQUE INDEX TDETAIL_ID ON TDETAIL(ID);
ALTER TABLE TDETAIL ADD CONSTRAINT TDETAIL_ID PRIMARY KEY(ID);

When open details Table Exception Raises, BCDField as master details because oracle type number with scalar(10,0) detected as BCDField. My delphi example, MapRules not working when i change NUMBER(10,0) to NUMBER(8,0) <-- from documentation with int32

type 
  TDetailHelper = class(TComponent)
  private
    FMaster: TFDTable;
    FMasterSource: TDataSource;
    FDetail: TFDTable;
  protected
    procedure DoInternalOpen;
end; 

procedure TDetailHelper.DoInternalOpen;
begin
  if not FMaster.Active then
  begin
    FMaster.TableName := 'TMASTER';
    FMaster.IndexName := 'TMASTER_ID';
  end;

  FDetail.TableName := 'TDETAIL';
  FDetail.MasterSource := FMasterSource;
  FDetail.IndexName    := 'TDETAIL_ID';
  FDetail.MasterFields := 'ID';
  FDetail.DetailFields := 'MASTERID';

  {Open ALL}
  FMaster.DisableControls;
  FDetail.DisableControls;
  try
    FMaster.Open; { <-- Open OK}
    FDetail.Open; { <-- Raise Exception}
  finally
    FMaster.EnableControls;
    FDetail.EnableControls;
  end;
end;

and i get this exception "Raises Invalid variant type or size for field 'ID'" someone can explain why this exception raises.

0

There are 0 answers