|
-
Actually I do have a good reason for bumping this. A problem has arisen. It seems that this Oracle statement above only works properly if the foreign keys between two tables are broken up into separate foreign key constraints. In other words, if there are multiple foreign keys between two tables AND those keys are stated in separate constraints on the parent table, that statement works. However, if there are multiple keys between two tables and those keys are defined in ONE constraint, the above doesn't function the same. Instead, it returns erroneous data.
I have a table named SET_STRAT_MTX. It has 3 foreign key relationships with SET_STRAT_MTXNAMES, which are defined in a single constraint simultaneously. Using the SQL Server query of
"SELECT OBJECT_NAME(FKEYID) AS TABLE_NAME,COL_NAME(FKEYID, FKEY) AS COLUMN_NAME,OBJECT_NAME(RKEYID) AS REFERENCED_TABLE_NAME, COL_NAME(RKEYID, RKEY) AS REFERENCED_COLUMN_NAME FROM SYSFOREIGNKEYS WHERE OBJECT_NAME(FKEYID)='SET_STRAT_MTX'"
It returns the 3 relationships by displaying the connection between the CATEGORY,SUBCAT, and MTXNUM columns in both tables. However, the Oracle statement
"SELECT A.TABLE_NAME, a.column_name,c.table_name as REFERENCED_TABLE_NAME,c.column_name as REFERENCED_COLUMN_NAME FROM user_cons_columns a,user_cons_columns c,user_constraints b WHERE a.constraint_name=b.constraint_name AND a.table_name=b.table_name AND A.TABLE_NAME = 'SET_STRAT_MTX' AND b.constraint_type='R' AND b.r_constraint_name=c.constraint_name"
matches up the column CATEGORY with CATEGORY in the other table, as it should, but it also matches it up with SUBCAT and MTXNUM. Then it does the same thing for the other two columns, given one proper match and two wrong matches. I have no idea why this is happening. Screen shots of the data would probably help; I'm at work now but maybe I can post some shots when I get home.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|