Copy Data from Parent Table
kkemerait
Posts: 7
I have a table called Client which has a Child table called Jobsite. When I auto-Generate what I want is that for each child row inserted I want it to COPY the column called CITY in the Parent Table into the Child Table (same column name) so that each child row has the SAME value for CITY as its Parent Table (Client) does.
I have tried Manual FK I have also tried writing a direct SQL statement, but while they USE the Column from Client the child records do not necessarily match the parent Record, so I end up with something like this:
CLIENT (parent)
100, Hartford, ...
101, NYC, ...
102, San Francisco
JOBSITE (child)
100, 102, NYC...
101, 100, San Francisco...
102, 101, Hartford
While what I want is this:
CLIENT (parent)
100, Hartford, ...
101, NYC, ...
102, San Francisco
JOBSITE (child)
100, 102, San Francisco...
101, 100, Hartford...
102, 101, NYC
I have turned off the shuffle data checkbox as well but to no avail. Can anyone help with this.
Thanks in advance
I have tried Manual FK I have also tried writing a direct SQL statement, but while they USE the Column from Client the child records do not necessarily match the parent Record, so I end up with something like this:
CLIENT (parent)
100, Hartford, ...
101, NYC, ...
102, San Francisco
JOBSITE (child)
100, 102, NYC...
101, 100, San Francisco...
102, 101, Hartford
While what I want is this:
CLIENT (parent)
100, Hartford, ...
101, NYC, ...
102, San Francisco
JOBSITE (child)
100, 102, San Francisco...
101, 100, Hartford...
102, 101, NYC
I have turned off the shuffle data checkbox as well but to no avail. Can anyone help with this.
Thanks in advance
Comments
Alternatively, you may also be able to do this with a Python generator. I don't have an exact code to do this but this may hopefully point you in the right direction.
If all else fails, however, another option is to configure your project to run a script after generation (File>Edit Project>Scripts) that will update the City column to the correct value, with something like the following:
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?