Mark Brady
2010-04-05 17:26:10 UTC
When I do it via Script I get one of a few outcomes:
1. If the child has a column with the same name as the parent... it
seems to work fine.
2. If not I get a either a new column in the child with the same name
3. Or it will change the name of the column that I want it to use
instead... e.g. I have two FK's to the same table.
______________________________________
Build this Oracle PDM
create table PARENT_T (
PARENT_PK NUMBER not null,
constraint PK_PARENT_T primary key (PARENT_PK)
);
create table CHILD_T (
ALT_PARENT_PK NUMBER
);
___________________________________________
This script will create a JOIN for the reference automagically, and it
will create a brand new column that wasn't there before
set tbl = activemodel.tables.item(0) '--- assumes this is parent if
not make it 1
set tbl2 = activemodel.tables.item(1) '--- assumes this is child if
not make it 0
Set ref = activemodel.references.createnewat( -1 , 0)
'
set ref.parenttable = tbl
set ref.childtable = tbl2
___________________________________________
So I tried to create the JOIN First, so maybe it would leave the child
table alone. But instead of adding a new column it just flat out
changed the name of the column to match the parent table.
set tbl = activemodel.tables.item(0) '--- assumes this is parent if
not make it 1
set tbl2 = activemodel.tables.item(1) '--- assumes this is child if
not make it 0
Set ref = activemodel.references.createnewat( -1 , 0)
'
'
Set jn = ref.joins.createnewat(-1, 0)
set jn.parenttableColumn = tbl.keys.item(0).columns.item(0)
set jn.ChildtableColumn = tbl2.columns.item(0)
set ref.parenttable = tbl
set ref.childtable = tbl2
___________________________________________
1. If the child has a column with the same name as the parent... it
seems to work fine.
2. If not I get a either a new column in the child with the same name
3. Or it will change the name of the column that I want it to use
instead... e.g. I have two FK's to the same table.
______________________________________
Build this Oracle PDM
create table PARENT_T (
PARENT_PK NUMBER not null,
constraint PK_PARENT_T primary key (PARENT_PK)
);
create table CHILD_T (
ALT_PARENT_PK NUMBER
);
___________________________________________
This script will create a JOIN for the reference automagically, and it
will create a brand new column that wasn't there before
set tbl = activemodel.tables.item(0) '--- assumes this is parent if
not make it 1
set tbl2 = activemodel.tables.item(1) '--- assumes this is child if
not make it 0
Set ref = activemodel.references.createnewat( -1 , 0)
'
set ref.parenttable = tbl
set ref.childtable = tbl2
___________________________________________
So I tried to create the JOIN First, so maybe it would leave the child
table alone. But instead of adding a new column it just flat out
changed the name of the column to match the parent table.
set tbl = activemodel.tables.item(0) '--- assumes this is parent if
not make it 1
set tbl2 = activemodel.tables.item(1) '--- assumes this is child if
not make it 0
Set ref = activemodel.references.createnewat( -1 , 0)
'
'
Set jn = ref.joins.createnewat(-1, 0)
set jn.parenttableColumn = tbl.keys.item(0).columns.item(0)
set jn.ChildtableColumn = tbl2.columns.item(0)
set ref.parenttable = tbl
set ref.childtable = tbl2
___________________________________________