|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Nov 2002
Posts: 18 Auckland, New Zealand
Member
|
OP
Member
Joined: Nov 2002
Posts: 18 Auckland, New Zealand |
Hi Marco - just wondering if there's been any progress on this - my customer is getting a little edgy!
Thanks Jim
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Aug 1999
Posts: 22,221
Member
|
Member
Joined: Aug 1999
Posts: 22,221 |
I have not yet been able to reproduce this.
------------------ Marco Kalter Allround Automations
Marco Kalter Allround Automations
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Nov 2002
Posts: 18 Auckland, New Zealand
Member
|
OP
Member
Joined: Nov 2002
Posts: 18 Auckland, New Zealand |
Marco: we have now managed to make the 'Field must have a value' error go away by setting the Required property of all relevant TStringfield objects to false.
Could I now refer you back to my earlier question re. detail synchronisation please.
To repeat, my TOracleDatasets don't seem to have BeforeRefresh or AfterRefresh events.
The only *Refresh* event is AfterRefreshRecord, which does not appear to be triggered by detail synchronisation - at least according to my testing. Is there any other event I could use?
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Aug 1999
Posts: 22,221
Member
|
Member
Joined: Aug 1999
Posts: 22,221 |
Sorry, I noticed that the AfterRefresh and BeforeRefresh events are not published in 3.4, so you can only set them at run-time. For example:[quote] procedure TMainForm.EmpDataSetAfterRefresh(DataSet: TDataSet);
begin
ShowMessage('AfterRefresh');
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
EmpDataSet.AfterRefresh := EmpDataSetAfterRefresh;
...
end; [/quote] ------------------ Marco Kalter Allround Automations [This message has been edited by mkalter (edited 17 April 2003).]
Marco Kalter Allround Automations
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Nov 2002
Posts: 18 Auckland, New Zealand
Member
|
OP
Member
Joined: Nov 2002
Posts: 18 Auckland, New Zealand |
Marco - thank you for that last reply, which was most helpful.
I have now almost finished the conversion!
However I am still having problems with Master/Detail relationships.
My question now is this: for master/detail relationships to work between two TOracleDatasets, must a Foreign Key (referential integrity) constraint exist IN THE DATABASE between the relevant tables?
Thanks again Jim
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Aug 1999
Posts: 22,221
Member
|
Member
Joined: Aug 1999
Posts: 22,221 |
No, these foreign keys do not need to exist. A foreign key merely allows the detail dataset to automatically create the appropriate MasterFields, DetailFields, Variables, and where clause at design time.
If this foreign key does not exist, you have to set the MasterFields, DetailFields, Variables, and where clause yourself.
------------------ Marco Kalter Allround Automations
Marco Kalter Allround Automations
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Nov 2002
Posts: 18 Auckland, New Zealand
Member
|
OP
Member
Joined: Nov 2002
Posts: 18 Auckland, New Zealand |
OK Marco - thanks for that. Unfortunately it doesn't help solve my problem, which I will now briefly describe.
In the Application there is a form featuring two TDBGrid components plus some TDBEdit and TEdit boxes.
Grid 1 is read-only and displays master table data - its DataSource property is set to a TDataSource component which links to a TOracleDataset containing SQL which queries the master table.
Grid 2 is updateable and relates to the Detail table (similar connection via a DataSource and a TOracleDataset). One of its columns is populated from a TStringfield component defined as a look-up field in a third (look-up) TOracleDataset.
The SQL for each TOracleDataset is set up at runtime, as is the master-detail relationship. Both master & detail datasets have CachedUpdates = true. At runtime the edit boxes are used to input data to the master table, which is then displayed in Grid 1. When the user clicks on a row in Grid 1, Grid 2 should display the corrsponding detail row(s) and/or allow the input of detail data relating to that master row.
In the BDE-based version all of this was working correctly. In the DOA version at present, the master-detail relationship breaks down. If the user inputs detail data for a master row, then moves to another master row, then returns to the first, those detail rows appear sometimes to have associated themselves with the wrong master row, and other times to have disappeared altogether. The look-up function however works properly.
Do you have any suggestions as to what might be happening here?
Thanks again Jim
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Aug 1999
Posts: 22,221
Member
|
Member
Joined: Aug 1999
Posts: 22,221 |
My guess is that the MasterFields or DetailFields property is not defined correctly.
Let's assume that you have a table "master" and a table "detail". A record in the master table is identified by an "id" column. The detail table has a "master_id" column that identifies the master.
In this case, the following properties need to be set for the detail dataset:
Master = <master dataset> MasterFields = id DetailFields = master_id SQL = select ... where master_id = :master_id
This should do the trick.
------------------ Marco Kalter Allround Automations
Marco Kalter Allround Automations
|
|
|
Re: 'Cannot update to null' errors - updateable TOracleDataset
|
Joined: Nov 2002
Posts: 18 Auckland, New Zealand
Member
|
OP
Member
Joined: Nov 2002
Posts: 18 Auckland, New Zealand |
YES - that's fixed it! I hadn't quite read the documentation closely enough and had included an extra column in the DetailFields property.
So a testing version of the module has just gone to the customer for appraisal - doubtless there will be a few issues still to be sorted, but I'm confident now that the bulk of the work has been done and that it's basically working.
Many thanks for all your help Marco. Cheers Jim
|
|
|
|
|
|