LocalMasterDetail did not work Correctly!!
Posted: Thu 29 Jul 2010 19:00
Dear DevArt;
After upgrade to ODAC 6.90.0.59 edition, a new issue raised in my applications, where I use LocalMasterDetail option I found the following:
1- Insert an new record in the Master table, without post;
2- Insert record in the Detail table, the record is inserted, but after post the detail record it become hidden ???
3- Post the mater record it will become visible again ????!!!
below a sample that demonstrate the issue, note that in ODAC 6.50.0.34 the issue are not exists ??!!!!!
Thanks in Advanced
Ahmed Hijazi P.Eng.
After upgrade to ODAC 6.90.0.59 edition, a new issue raised in my applications, where I use LocalMasterDetail option I found the following:
1- Insert an new record in the Master table, without post;
2- Insert record in the Detail table, the record is inserted, but after post the detail record it become hidden ???
3- Post the mater record it will become visible again ????!!!
below a sample that demonstrate the issue, note that in ODAC 6.50.0.34 the issue are not exists ??!!!!!
Thanks in Advanced
Ahmed Hijazi P.Eng.
Code: Select all
var
snConnection : TOraSession;
tblDepts, tblEmps : TOraTable;
dsDepts : TOraDataSource;
begin
snConnection := TOraSession.Create(self);
tblDepts := TOraTable.Create(self);
tblEmps := TOraTable.Create(self);
dsDepts := TOraDataSource.Create(self);
with snConnection do begin
Options.Direct := True;
Username := 'dblock';
Password := 'dblock';
Server := 'gisserver::gisdb';
AutoCommit := False;
Connect;
try
ExecSQL('drop table Emps', []);
ExecSQL('drop table Depts', []);
except
end;
ExecSQL('create table DEPTS(OID NUMBER(8) not null, NAME VARCHAR2(50) not null, constraint TBLMASTER_PK primary key (OID))', []);
ExecSQL('create table EMPS(OID NUMBER(8) not null, NAME VARCHAR2(50),DEPT_OID NUMBER(8),constraint EMPS_PK primary key (OID), constraint EMPS_FK foreign key (DEPT_OID) references DEPTS (OID))', []);
end;
with tblDepts do begin
TableName := 'DEPTS';
KeyFields := 'OID';
Session := snConnection;
CachedUpdates := True;
end;
dsDepts.DataSet := tblDepts;
with tblEmps do begin
TableName := 'EMPS';
MasterFields := 'OID';
DetailFields := 'DEPT_OID';
MasterSource := dsDepts;
KeyFields := 'OID';
Session := snConnection;
CachedUpdates := True;
Options.LocalMasterDetail := True;
end;
tblDepts.open;
tblEmps.Open;
tblDepts.Insert;
tblDepts.FieldByName('OID').Value := 1;
tblDepts.FieldByName('Name').Value := 'Dept A';
// Note that I have not Post, in my case i need the Detail recod to be inserted first then Post the Master Record.
with tblEmps do begin
Append;
FieldByName('OID').Value := 1;
FieldByName('Name').Value := 'Emp A';
FieldByName('Dept_OID').Value := 1;
Post;
Append;
FieldByName('OID').Value := 2;
FieldByName('Name').Value := 'Emp B';
FieldByName('Dept_OID').Value := 1;
Post;
// Values will not appears ??, in the ODAC 6.50.0.34, it work fine, but in ODAC6.90.0.57 it's not !!!!!
First;
ShowMessage(FieldByName('Name').AsString); // Empty string displayed
Next;
ShowMessage(FieldByName('Name').AsString); // Empty string displayed
// But after I execute the post of the master table is shown normaly !!!!!
tblDepts.Post;
First;
ShowMessage(FieldByName('Name').AsString); // "Emp A" displayed
Next;
ShowMessage(FieldByName('Name').AsString); // "Emp B" displayed
end;