473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using Foreign Key To Ref A Unique Index

I have a PARENT/CHILD I'm attempting to attach another CHILD to. When I try to add a FOREIGN KEY to the 3rd table referring to CHILD1 (AGTERNS), I get error SQL0573N A column list specified in the references clause of constraint
"RCAGTRNZ" does not identify a unique constraint of the parent table
"VCSTSTNT.AGTERNS".

Since CHILD1 has multiple constraints, a unique index and a foreign key, is there a gotcha that I'm not aware of? Thanks a lot.

My field names and lengths all seem to match on the DDL and I've even tried dropping and re-creating the child.

Here is the first child definition:

;
CREATE TABLE VCSTSTNT.AGTERNS
(
COMPANY_CODE CHAR(3) NOT NULL WITH DEFAULT,
AGENT_ID CHAR(10) NOT NULL WITH DEFAULT,
SEGMENT_ID CHAR(2) NOT NULL WITH DEFAULT,
PERIOD_END_DTE DEC(8,0) NOT NULL WITH DEFAULT,
SEQUENCE_NUMBER DEC(2,0) NOT NULL WITH DEFAULT,
BUSINESS_CODE DEC(2,0) NOT NULL WITH DEFAULT,
LEVEL_1_FIRST_YEAR DEC(11,2) NOT NULL WITH DEFAULT,
OWRITE_FIRST_YEAR DEC(11,2) NOT NULL WITH DEFAULT,
LEVEL_1_RENEWALS DEC(11,2) NOT NULL WITH DEFAULT,
OVERWRITE_RENEWALS DEC(11,2) NOT NULL WITH DEFAULT,
TOTAL_ADVANCES DEC(11,2) NOT NULL WITH DEFAULT,
ADV_OFSET_BY_EARN DEC(11,2) NOT NULL WITH DEFAULT,
ADV_OFF_BY_RECOUP DEC(11,2) NOT NULL WITH DEFAULT,
ADVANCE_BALANCE DEC(11,2) NOT NULL WITH DEFAULT,
LEVEL_1_COMM DEC(11,2) NOT NULL WITH DEFAULT,
OVERWRITE_COMM DEC(11,2) NOT NULL WITH DEFAULT,
RETAIN_COM_BAL DEC(11,2) NOT NULL WITH DEFAULT,
LEVEL_1_COI DEC(11,2) NOT NULL WITH DEFAULT,
OVERWRITE_COI DEC(11,2) NOT NULL WITH DEFAULT,
LEVEL_1_SRV_FEE DEC(11,2) NOT NULL WITH DEFAULT,
OVERWRITE_SRV_FEE DEC(11,2) NOT NULL WITH DEFAULT,
LEVEL_1_ALLOW DEC(11,2) NOT NULL WITH DEFAULT,
OVERWRITE_ALLOW DEC(11,2) NOT NULL WITH DEFAULT,
FOREIGN KEY RCAGTRNS
( COMPANY_CODE,
AGENT_ID,
SEGMENT_ID,
PERIOD_END_DTE )
REFERENCES VCSTSTNT.AGTERN
ON DELETE CASCADE
) IN TAGTERNS
;
CREATE UNIQUE INDEX VCSTSTNT.IAGTRNS1
ON VCSTSTNT.AGTERNS
(
COMPANY_CODE ASC,
AGENT_ID ASC,
SEGMENT_ID ASC,
PERIOD_END_DTE ASC,
SEQUENCE_NUMBER ASC
)
;

Here is the second child definition (AGTERNZ):

CREATE TABLE VCSTSTNT.AGTERNZ
(
COMPANY_CODE CHAR(3) NOT NULL WITH DEFA
AGENT_ID CHAR(10) NOT NULL WITH DEFA
SEGMENT_ID CHAR(2) NOT NULL WITH DEFA
PERIOD_END_DTE DEC(8,0) NOT NULL WITH DEFA
SEQUENCE_NUMBER DEC(2,0) NOT NULL WITH DEFA
BUSINESS_CODE DEC(2,0) NOT NULL WITH DEFA
BONUS_PLAN_ID CHAR(8) NOT NULL WITH DEFA
BONUS_ALLOWANCES DEC(11,2) NOT NULL WITH DEFA
BONUS_ALLOWANCE_ADVANCES DEC(11,2) NOT NULL WITH DEFA
BONUS_ADV_OFFSET_BY_EARNINGS DEC(11,2) NOT NULL WITH DEFA
BONUS_ADV_OFFSET_BY_RECOUPMENT DEC(11,2) NOT NULL WITH DEFA
)
IN TAGTERNZ
;
CREATE UNIQUE INDEX VCSTSTNT.IAGTRNZ1
ON VCSTSTNT.AGTERNZ
( COMPANY_CODE ASC,
AGENT_ID ASC,
SEGMENT_ID ASC,
PERIOD_END_DTE ASC,
SEQUENCE_NUMBER ASC,
BUSINESS_CODE ASC,
BONUS_PLAN_ID ASC )
;
ALTER TABLE VCSTSTNT.AGTERNZ
ADD CONSTRAINT RCAGTRNZ
FOREIGN KEY
( COMPANY_CODE,
AGENT_ID,
SEGMENT_ID,
PERIOD_END_DTE,
SEQUENCE_NUMBER )
REFERENCES VCSTSTNT.AGTERNS
( COMPANY_CODE,
AGENT_ID,
SEGMENT_ID,
PERIOD_END_DTE,
SEQUENCE_NUMBER )
ON DELETE CASCADE
;

Ken H.
Jul 7 '06 #1
1 3760
problem resolved
Jul 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: KULJEET | last post by:
foreign key also refer to unique constraint. (GREAT...) 1.then table that containt unique constraint act as master table????? 2.IS unique constraint will replace with primary key?? 3.Is unique...
2
by: geoff | last post by:
The table creation script(at the end of this post) works fine on 4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I am starting the server with the same command for both...
6
by: Chris Foster | last post by:
I am trying to implement a very fast queue using SQL Server. The queue table will contain tens of millions of records. The problem I have is the more records completed, the the slower it gets....
31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
10
by: teddysnips | last post by:
Application is a Work Tracking/Timesheet database. The increments of work are stored in the TimesheetItem table. This contains, inter alia, the Work Code, the Start and the Duration that the...
1
by: Jonathan Scott via AccessMonster.com | last post by:
I have an application who's backend has a relationship defined one to one. I need to update the LIVE version of the database to reflect this for the new version. How can I express such a foreign...
2
by: Benjamin Smith | last post by:
I have two tables like following: create table attendancereport ( id serial unique not null, staff_id integer not null references staff(id), schoolyear varchar not null references...
1
by: Robert Fitzpatrick | last post by:
I am running PostgreSQL 7.4.5 and have a trigger on a table called tblriskassessors which inserts, updates or delete a corresponding record in tblinspectors by lookup of a contact id and license...
5
by: Rico | last post by:
Hello, I have a relationship that I'd like to modify using DAO. Right now the Cascading updates are off, but I'd like to add them and I'm not sure the best way to do that. Any ideas? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.