No primary key value for foreign key

Hi,

I tried to:

alter table sa.shipitems
   add foreign key FK_SHIPITEM_REFERENCE_OITEMS (oitemsid)
      references sa.oitems (oitemsid)
      on update cascade
      on delete restrict

but got this error:

No primary key value for foreign key 'FK_SHIPITEM_REFERENCE_OITEMS' in table
'shipitems'

What does it mean and how to round this problem?


fyi, here is the definition of both table

/*==============================================================*/
/* Table: shipitems                                             */
/*==============================================================*/
create table sa.shipitems
(
    shipitemsid          numeric(10)                    not null default
autoincrement,
    oitemsid             numeric(10)                    not null,
    shipid               numeric(10),
    qty                  decimal(10,2),
    primary key (shipitemsid)
);

/*==============================================================*/
/* Table: oitems                                                */
/*==============================================================*/
create table sa.oitems
(
    oitemsid             numeric(10)                    not null default
autoincrement,
    orderid              numeric(10)                    not null,
    itemid               numeric(10)                    not null,
    itemnm               char(100)                      not null,
    qty                  money                          not null,
    itemprice            money                          not null,
    itemdisc             money,
    primary key (oitemsid)
);


thanks a lot

Rony



0
Rony
3/30/2005 1:03:38 AM
sybase.powerbuilder.database 9855 articles. 2 followers. Follow

2 Replies
1189 Views

Similar Articles

[PageSpeed] 40

It means there is a value in sa.shipitems.oitemsid that is not in
sa.oitems.oitemsid.

The database cannot apply the foreign key because it is not valid.

Run this query:

select * from sa.shipitems where oitemsid not in
    ( select oitemsid from sa.oitems)

And that will find the offender.


"Rony Santoso" <rony_xg@yahoo.de> wrote in message
news:4249faea@forums-1-dub...
> Hi,
>
> I tried to:
>
> alter table sa.shipitems
>    add foreign key FK_SHIPITEM_REFERENCE_OITEMS (oitemsid)
>       references sa.oitems (oitemsid)
>       on update cascade
>       on delete restrict
>
> but got this error:
>
> No primary key value for foreign key 'FK_SHIPITEM_REFERENCE_OITEMS' in
table
> 'shipitems'
>
> What does it mean and how to round this problem?
>
>
> fyi, here is the definition of both table
>
> /*==============================================================*/
> /* Table: shipitems                                             */
> /*==============================================================*/
> create table sa.shipitems
> (
>     shipitemsid          numeric(10)                    not null default
> autoincrement,
>     oitemsid             numeric(10)                    not null,
>     shipid               numeric(10),
>     qty                  decimal(10,2),
>     primary key (shipitemsid)
> );
>
> /*==============================================================*/
> /* Table: oitems                                                */
> /*==============================================================*/
> create table sa.oitems
> (
>     oitemsid             numeric(10)                    not null default
> autoincrement,
>     orderid              numeric(10)                    not null,
>     itemid               numeric(10)                    not null,
>     itemnm               char(100)                      not null,
>     qty                  money                          not null,
>     itemprice            money                          not null,
>     itemdisc             money,
>     primary key (oitemsid)
> );
>
>
> thanks a lot
>
> Rony
>
>
>


0
Daniel
3/30/2005 1:16:14 AM
Dan,

I deleted the offender and successfully applied RI

many thanks
rony

"Daniel Coppersmith" <daniel_N.0.S.P.A.M_at_InFrontSoftware_D0T_C0M> wrote
in message news:4249fdde$1@forums-1-dub...
> It means there is a value in sa.shipitems.oitemsid that is not in
> sa.oitems.oitemsid.
>
> The database cannot apply the foreign key because it is not valid.
>
> Run this query:
>
> select * from sa.shipitems where oitemsid not in
>     ( select oitemsid from sa.oitems)
>
> And that will find the offender.
>
>
> "Rony Santoso" <rony_xg@yahoo.de> wrote in message
> news:4249faea@forums-1-dub...
> > Hi,
> >
> > I tried to:
> >
> > alter table sa.shipitems
> >    add foreign key FK_SHIPITEM_REFERENCE_OITEMS (oitemsid)
> >       references sa.oitems (oitemsid)
> >       on update cascade
> >       on delete restrict
> >
> > but got this error:
> >
> > No primary key value for foreign key 'FK_SHIPITEM_REFERENCE_OITEMS' in
> table
> > 'shipitems'
> >
> > What does it mean and how to round this problem?
> >
> >
> > fyi, here is the definition of both table
> >
> > /*==============================================================*/
> > /* Table: shipitems                                             */
> > /*==============================================================*/
> > create table sa.shipitems
> > (
> >     shipitemsid          numeric(10)                    not null default
> > autoincrement,
> >     oitemsid             numeric(10)                    not null,
> >     shipid               numeric(10),
> >     qty                  decimal(10,2),
> >     primary key (shipitemsid)
> > );
> >
> > /*==============================================================*/
> > /* Table: oitems                                                */
> > /*==============================================================*/
> > create table sa.oitems
> > (
> >     oitemsid             numeric(10)                    not null default
> > autoincrement,
> >     orderid              numeric(10)                    not null,
> >     itemid               numeric(10)                    not null,
> >     itemnm               char(100)                      not null,
> >     qty                  money                          not null,
> >     itemprice            money                          not null,
> >     itemdisc             money,
> >     primary key (oitemsid)
> > );
> >
> >
> > thanks a lot
> >
> > Rony
> >
> >
> >
>
>


0
Rony
3/30/2005 6:25:34 AM
Reply:

Similar Artilces:

no primary key value for foreign key value error in Master-Detail Dataset
Hi, We are using master detail relationship dataset but getting primary key violation error during posting the data. ------------------------------- *Project GBlWare.exe raised exception class EASANativeException with message* *[FireDAC][Phys][ODBC][Sybase][SQLAnywhere]no primary key value for foreign key* ------------------------------- Our current master detail scenario is that ,we are using parameter in details dataset that reference to master dataset primary key field value. But when I add a new record at that time master dataset key value is null. So when I press tab or down ...

integer primary/foreign key vs. varchar(255) primary/foreign key
Hello. Is there any principal performance (or some other) difference between using the integer primary/foreign key and using the string (varchar(255)) keys in queries that use tables joins? Server is Sybase SQL Anywhere 5.5.04 Yes! The primary key will only be made up of 12 bytes. By using an integer you ensure that your entire column is in the key. -- Jim Egan [TeamPS] Dynamic Data Solutions, Inc. http://www.dyn-data.com Houston, TX *********************************************************** Enterprise Applications in Your F...

Primary key
Hello, I've got a modeling problem betwin a conceptual model and a physical model and espacially about the foreign key. See below the illustrated exemple of the problem : -Whether the entity � ARTICLE � with two informations : CODE & WORDING -Whether the entity � UNITE � with two informations : CODE & WORDING An article has necesseraly three unity, the unity of command, of storage and of sails. These three unity can be differents. Conceptual model phycical model The generated physical model doesn't suitable me. How ...

Primary Key/Foreign Key
Can I use SQL Commands to add Primary key or reference keys to existed tables? (Not a new table, that's why I can't use CREATE TABLE command.) If does, could someone give me some sample codes? Thanks. Hi John, What you need is the ALTER TABLE statement. Look for it in SQLA help for the syntax. Regards, Nat. John Chyan wrote in message <35A4FF5D.5F192806@dissol.com>... >Can I use SQL Commands to add Primary key or reference keys to existed >tables? (Not a new table, that's why I can't use CREATE TABLE command.) > >If does, could someone ...

Primary key/Foreign key again
Thanks, Nat and David. Under "SQL Anywhere", I get into ISQL to use "ALTER TABLE" command to add my primary key: ALTER TABLE Client ADD PRIMARY KEY (SYSID) I got an error: user 'dba' has the row in 'Client' locked. How can I release the locking condition? Click on another table in Sybase Central. Is suspect this is the issue. Dave Wolf Jaguar Product Team John Chyan wrote: > Thanks, Nat and David. > > Under "SQL Anywhere", I get into ISQL to use "ALTER TABLE" command > to add my primary key: > ...

foreign key as a primary key
hi, I am using a foreign key (which is a primary key in a secondary table) as a primary key in a primary table. There is also another primary key in the primary table. Do You have to declare the foregin key as a primary key ? regards Jan Eikeland email:jaeikela@c2i.net url :http://home.c2i.net/jaeikela In article <368b0234.5056065@forums.powersoft.com>, jaeikela@c2i.net says... > hi, > > I am using a foreign key (which is a primary key in a secondary table) > as a primary key in a primary table. > There is also another primary key in the primary table...

SQL statement failed: (-194) No primary key value for foreign key
I'm getting this error message sporadically when my remote sites are replicating to my central server. The odd thing is the record that is the primary key value does exist! I'm at a lost...Does any have any idea, why this may be happening? Thanks Tasha Did the record exist at the time the error was reported? I have seen cases before where the Parent record is physically sent to the remote *after* the Child record. This would explain why the error was legitimately reported but when you look at the database later the Parent record now exists. -- -------------...

primary key and foreign Key????
 Hi i have 2 table.. Table1UID         Username1               AB2               CD3               DD Table 2ITEM       Price          UIDPOO1      20.00          1POO2      10.00          2POO3       15.00         1 Now i am letting the Admin to delete the user in table1But since UID 1 and 2 are ...

Keys, keys,keys...
Just installed PGP 6.5.8 and all is running fine, so far :-) Question: When I opened the PGP Keys window for the first time, apart from the *Create Key* wizard, there are about 50 odd keys belonging to various and sundry at NAI. Were these supplied for a purpose or only for illustration? Is there any reason they could not or should no be deleted? Question 2: I sent someone an encrypted test message using that person's public key. It went off fine except, I am left with only the encrypted eMail. What setting should I change in order for my eMail client (Outlook 2000) ...

SQL statement failed, no primary key value for foreign key ... in table ...
Problem: SQL statement failed, no primary key value for foreign key ... in table ... After deleting or changing primary key values in either consolidated or remote database. Question: Are there any triggers that can resolve inserting a record that has a foreign key value with no existing primary key value in primary table? Description: We have a serious problem with the dbremote program. I think it's a general problem that could appear in every database with related tables. Everytime the problem turns up we must create new remote databases from the consolidated datab...

No primary key value for foreign key 'ISYSTABCOL' in table 'ISYSCOLPERM'
Hi all, running SA 10.0.1.3686 and .3712 on Win 2003 Server SP1. The above message appears when I try to add a column to a table. It's just a simple one: alter table dbo.T_MaZuGavAktion add fkz_BeilageNrLautVersand int check (@Wert > 0) null; There is a view based on this table, and several users have been granted update column rights on this view. It is only possible to execute the "ALTER TABLE ADD column null" statement when I revoke the update column rights from the view before (and re-grant them afterwards). That happened once in the past week...

Primary key
> Je me permet de soliciter une aide sur poweramc V8. > Je suis en charge d'un projet ERP et je me pose la question suivante sur un > exemple de mod�lisation. > > Entit� : ARTICLE > information : Code article > Information : Libell� article > > Entit� : Unit� > Information : Code unit� (exemple : Kg, palette, m2...) > information : Libell� unit� > > Un article a 3 unit�s, unit� de stockage, unit� de vente et unit� d'achat. > Ces trois unit�s peuvent �tre diff�rentes. > > Dans mon MCD, j'...

Foreign keys have the same columns as primary key
After upgrading from AppModeler 6.0 to 6.1 when I check my PDM I'm getting the following warning messages on a lot of columns: Foreign Keys have the same columns as primary key. The suggested correction doesn't help much. Can some one explain this warning to me? It seems that when the primary key of one table is a foreign key from another table this warning is poping up. Any help appreciated. Thanks, -- James L. Knowlton President and Programer/Analyst Law Enforcement Automated Data Systems, Inc Richmond, VA begin 666 James L. Knowlton.vcf M0D5'24XZ5D-!4D0-&q...

composite primary key and foreign key
I refer a composite primary key of a master table, I have to refer all the fields of the composite primary key. But how to partially refer the composite primary key in a child table? For example, if PARENT table  has primary key (A,B,C), how to create a foreign key in CHILD table which will refer only (A,B) fields of Table1?  Hi, Please refer to the following description: MSDN: In a foreign key reference, a link is created between two tables when the column or columns that hold the primary key value for one table are referenced by the column or columns in another table...

Web resources about - No primary key value for foreign key - sybase.powerbuilder.database

Primary market - Wikipedia, the free encyclopedia
of securities dealers. The process of selling new issues to investors is called underwriting . In the case of a new stock issue , this sale is ...

MYEFO health cuts pummel Primary Health Care and Sonic Healthcare
Hefty government cuts to pathology and diagnostic imaging incentives&nbsp;have sparked a sharp sell-off of&nbsp;healthcare stocks.

Aranda Primary School students make French pen pals the old-fashioned way
... in touch with international friends, opting for old-fashioned snail mail. Technology has made our world smaller, but one group of Aranda Primary ...

MYEFO health cuts pummel Primary Health Care and Sonic Healthcare
Hefty government cuts to pathology and diagnostic imaging incentives have sparked a sharp sell-off of healthcare stocks.

Larwyn’s Linx: Movement to Primary Speaker Paul Ryan Out of Congress Picks Up Steam
Send us tips ! Bloggers: install a Larwyn's Linx widget . Get real-time news, 24/7, at BadBlue . Nation Movement to Primary Speaker Paul Ryan ...

YouTube and NBC News present Democratic primary debate in South Carolina
... month, we’ll join together with NBC News to present the final DNC sanctioned Democratic presidential debate before the first caucus and primary ...

Ted Cruz Woos SEC Primary Voters with Vows to Roll Back Obama Policies at Alabama Rally
Sen. Ted Cruz (R-TX) is off and running on his “Take Off with Ted Cruz Country Christmas Tour.”


30 Percent Of Republican Primary Voters Want To Bomb Aladdin's Fictional City
... evangelical Christians, and ignorance. Good grief. According to a new Public Policy Polling (PPP) poll , 30 percent of Republican primary ...

Who Will Sen. Tim Scott Endorse Ahead Of South Carolina Primary?
Who Will Sen. Tim Scott Endorse Ahead Of South Carolina Primary?

Resources last updated: 12/25/2015 8:28:38 AM