473,606 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Foreign Key To Ref A Unique Index

2 New Member
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.AGTER NS".

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.AGTERN S
(
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_Y EAR DEC(11,2) NOT NULL WITH DEFAULT,
OWRITE_FIRST_YE AR DEC(11,2) NOT NULL WITH DEFAULT,
LEVEL_1_RENEWAL S DEC(11,2) NOT NULL WITH DEFAULT,
OVERWRITE_RENEW ALS DEC(11,2) NOT NULL WITH DEFAULT,
TOTAL_ADVANCES DEC(11,2) NOT NULL WITH DEFAULT,
ADV_OFSET_BY_EA RN DEC(11,2) NOT NULL WITH DEFAULT,
ADV_OFF_BY_RECO UP 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_F EE 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.IAGTRN S1
ON VCSTSTNT.AGTERN S
(
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.AGTERN Z
(
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_ALLOWANCE S DEC(11,2) NOT NULL WITH DEFA
BONUS_ALLOWANCE _ADVANCES DEC(11,2) NOT NULL WITH DEFA
BONUS_ADV_OFFSE T_BY_EARNINGS DEC(11,2) NOT NULL WITH DEFA
BONUS_ADV_OFFSE T_BY_RECOUPMENT DEC(11,2) NOT NULL WITH DEFA
)
IN TAGTERNZ
;
CREATE UNIQUE INDEX VCSTSTNT.IAGTRN Z1
ON VCSTSTNT.AGTERN Z
( 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.AGTERN Z
ADD CONSTRAINT RCAGTRNZ
FOREIGN KEY
( COMPANY_CODE,
AGENT_ID,
SEGMENT_ID,
PERIOD_END_DTE,
SEQUENCE_NUMBER )
REFERENCES VCSTSTNT.AGTERN S
( COMPANY_CODE,
AGENT_ID,
SEGMENT_ID,
PERIOD_END_DTE,
SEQUENCE_NUMBER )
ON DELETE CASCADE
;

Ken H.
Jul 7 '06 #1
1 3769
ken_knee
2 New Member
problem resolved
Jul 21 '06 #2

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

Similar topics

3
11194
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 constraint gives all fuctionality as primary key constraint??? thanks kuljeet pal singh
2
3910
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 versions: mysqld-max-nt --console --transaction-isolation=SERIALIZABLE In 4.0.15-win I can extract the following error after I run the table creation script: ERROR 1005: Can't create table '.\ibdata\#sql-a14_3.frm'
6
9118
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. I don't want to remove data from the queue because I use the same table to store results. The queue handles concurrent requests. The status field will contain the following values: 0 = Waiting
31
3358
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 customer subtypes: 1 - business, 2 - home, 3 - university
10
2109
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 employee spent that day on a particular project. Some employees in the Network Support Department don't complete a standard 7.5 hour day for various reasons, so for every Network Support person I need to update these particular days with an amount...
1
2094
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 key constraint in DDL? I tried creating a foreign key constraint, and then making a unique index on the field in the foreign table, and vice versa, and neither has worked. My schema diff utility tells me there is still a one to many relationship at...
2
3004
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 schoolyear(year), students_id integer not null references students(id) ); // schoolyear.year in format "2003 - 2004".
1
4565
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 number match. The INSERT and DELETE work fine. The UPDATE works good unless I update the license number. The error, at the bottom of this message, suggests the primary key violation. But my UPDATE in no way alters the primary key, which is...
5
3854
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? Thanks!
0
8010
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8433
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8429
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8084
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6761
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5963
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5461
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3969
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.