|
Log in | ||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
If there are any example on how to setup a simple master/details database that when you insert a new record in the master, it will create one automatically in the details, please let me know.
Right now I am getting this error: NexusDB: nxTable_trials: Referential Integrity Violation. Trials(Project_No) -> Projects(Project_No): Master record missing. [$2605/9733]. My master database is called projects: Project_No (autoinc) Description Details database is called trials: Trial_No Project_No Description In the referential integrity of trials, I tell that Project_No from trial to be associated with Project_No from project. I do the same thing under the component nxTable_trials. I tell it what the mastersource is and assign the index to match. Under the newrecord property of the master table, I have this command: nxTable_trials. insert; // to create a new detail record when a master one is created. Under the new record property of the detail table, I have: EmbeddedDM.nxTable_trials.FieldValues['Project_No'] := EmbeddedDM.nxTable_Projects.FieldByName('Project_N o') .AsInteger; Do I have to write that? Or is that supposed to be assign automatically? Well, anyway, this setup triggers the error I wrote above. If some kind soul can tell me on how to fix that, that would lower my frustration level. Thanks. P |
|
#2
|
|||
|
|||
|
On Mon, 5 Mar 2012 09:53:13 +1100, pierrotsc
<pierrotsc.58xct6@nx-forums.nexusdb.com> wrote: > >In the referential integrity of trials, I tell that Project_No from >trial to be associated with Project_No from project. > That's ok. Also in Actions check off Target Required. >I do the same thing under the component nxTable_trials. I tell it what >the mastersource is and assign the index to match. This is just for your DB grids to display correct child rows. >Under the newrecord property of the master table, I have this command: >nxTable_trials. insert; // to create a new detail record when a master >one is created. .... >Do I have to write that? Or is that supposed to be assign >automatically? After you insert new master record, get Primary Key for it ('('Project_No') using LASTAUTOINC. When you insert new row in detail table, populate it's 'Project_No' with this value. Nothing is automatically assigned. |
|
#3
|
|||
|
|||
|
Not sure if you know about this, if you right click the database in
Enterprise Manager and select referential integrity a simple GUI editor comes up, in your example all you would then need to do is drag the ProjectNo from the Details to the Master ProjectNo to create the link. On 04/03/2012 22:53, pierrotsc wrote: > If there are any example on how to setup a simple master/details > database |
|
#4
|
|||
|
|||
|
Quote:
Is that something i set in my datbase structure? Right now the field of Project_no is set to autoinc. When i insert a new record, I just click on a + in the navigation toolbar of my grid. Thanks. P |
|
#5
|
|||
|
|||
|
On 05/03/2012 15:12, pierrotsc wrote:
> Zoran;91543 Wrote: >> >> After you insert new master record, get Primary Key for it >> ('('Project_No') using LASTAUTOINC. Zoran is making reference to when your inserting records using SQL, if your using nxTables, and your using MasterSource etc, then you don't need to do anything when inserting new records, Delphi MasterSource will handle that for you. |
|
#6
|
|||
|
|||
|
Assuming (in the meantime) you didn't change position in the master table... ![]() I seldom use nxTable. That's why I was thinking 'sql'... Thanks for clarification. On Mon, 05 Mar 2012 15:46:26 +0000, "Keith Johnson[NDX]" <kpj_comp@yahoo.co.uk> wrote: >Zoran is making reference to when your inserting records using SQL, if >your using nxTables, and your using MasterSource etc, then you don't >need to do anything when inserting new records, Delphi MasterSource will >handle that for you. |
|
#7
|
|||
|
|||
|
On 05/03/2012 20:58, Zoran wrote:
> > Assuming (in the meantime) you didn't change position in the master > table... ![]() Correct, but of course that would be the desired effect ![]() For DB Editing my personal favourite is memory table backed TnxTables, you get the benefits of TDataset event notification without the pitfalls. TDataset event notification isn't as bad as some people make out if you understand it's principles. But for reports etc, SQL is my weapon of choice. |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Referential Integrity question | Scott Slater | nexusdb.public.support | 3 | 15th February 2012 07:41 AM |
| Referential Integrity | pierrotsc | nexusdb.public.support | 2 | 25th January 2012 12:18 PM |
| Referential Integrity | Mark Mitton | nexusdb.public.support | 1 | 3rd March 2006 01:09 PM |
| Re: V2 and referential integrity | Robert Meek | nexusdb.public.support | 1 | 13th March 2005 09:14 AM |
| Referential integrity! | Atmapuri | nexusdb.public.support | 6 | 30th September 2003 08:45 AM |