I ask to add a new property for TField. It must show, if the field must be updated in database when I update it in my program.
Sample query:
select t1.*, t1.rowid, t2.name as ABC_NAME
from table1 t1, table2 t2
where t1.id_abc = t2.id_abc(+)
table2 - table directory, from which the user can choose the value
My source code:
procedure TForm1.OracleDataSet1AfterOpen(DataSet: TDataSet);
begin
// My new property
OracleDataSet1.FieldByName('ABC_NAME').NotModify := True;
end;
procedure TForm2.DBGrid1DblClick(Sender: TObject);
begin
OracleDataSet1.Edit;
OracleDataSet1.FieldByName('id_abc').AsInteger := OracleDataSet2.FieldByName('id_abc').AsInteger;
OracleDataSet1.FieldByName('ABC_NAME').AsString := OracleDataSet2.FieldByName('name').AsString;
OracleDataSet1.Post;
end;
Must send the command to update to the database only for the field 'id_abc'!
I don't REFRESH OracleDataSet1 or only one record in it (RefreshRecord) because the query selects a lot rows and in practice very complex queries and large (long run). In addition it saves bandwidth and time.
Event 'AfterOpen' is used because prior to the opening OracleDataSet1 we don't know the exact type of data
some fields (example: NUMBER or NUMBER(5)), the disorder in the databases
. If fields can be determined in advance on some database to get an error OracleDataSet1: Type mismatch for field 'ID_ABC', expecting: Float actual: Integer.
For myself, I added a property "NotModify" (Boolean) for TOracleDataset. Please add this to the list of enhancement request.