I am unable to create the Foreign key

Hi,
I need to create the Foreign key which reffered to composite primary key.
the following table structure
Parent table
DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE, CATEGORY, STATEMENT, USER_ID, RECORD_MODIFICATION_DATE
Here composite primary key columns(DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE)
Child Table
DIVISION          VARCHAR2 (4)          
PROJECT_NUMBER          NUMBER (10)COMPETITION_PROJECT_NUMBER     NUMBER (10)          
COMPETITIVE_STMT_TYPE          VARCHAR2 (2)          
SEQUENCE     NUMBER (2)          
CATEGORY          VARCHAR2 (100)     
STATEMENT     LONG          
USER_ID     VARCHAR2 (100)          
RECORD_MODIFICATION_DATE     DATE     
ALTER TABLE COMPETITION_STMT ADD (CONSTRAINT COMPET_STMT_FK_PROJ_NUM foreign key
          (PROJECT_NUMBER) REFERENCES PROD_COMPET_XREF (PROJECT_NUMBER));
when i am trying to create foreign key i got this error
ORA-02270: no matching unique or primary key for this column-list
this is production issue Please help me.
Thanks in advance
Regards
Kumar.s

ALTER TABLE PROD_COMPET_XREF ADD (
CONSTRAINT PROD_COMP_XREF_PK_DPNCPNCT
PRIMARY KEY
(COMPETITION_PROJECT_NUMBER, PROJECT_NUMBER, DIVISION, PRODUCT_LOC_INDICATOR)
When you create a foreign key, it must reference a unique or primary key. The primary or Unique key must consist ONLY of those columns upon which the Primary key is based.
You must Alter the table and add a Unique key if you want to keep your compsite primary key constraint. The Unique key must be for only the column that your foreign key references. Then try to recreate your foreign key.
I doubt you will be able to add a foreign key because I suspect you might have multiple rows with the same value for this column based on your composite key; however, if you only intend for the project number to be listed only once and to be unique for each row, then the unique key may work or you may want to revist your primary key on this table. Perhaps you don't need it to be a composite PK???
If you can't work around that, one thing you can do is build a table based just on PROJECT_NUMBER that contains details about the project number and have other tables reference that. That is, if you have multiple rows with the same project number in that table. You may already have one? Perhaps you can build your foreign key to reference that?

Similar Messages

  • Questions about creating a foreign key on a large table

    Hello @ll,
    during a database update I lost a foreign key between two tables. The tables are called werteart and werteartarchiv_pt. Because of its size, werteartarchiv_pt is a partitioned table. The missing foreign key was a constraint on table werteartarchiv_pt referencing werteart.
    Some statistics about the sizes of the mentioned tables:
    werteart 22 MB
    werteartarchiv_pt 223 GB
    werteartarchiv_pt (Index) 243 GB
    I tried to create the foreign key again, but it failed with the following error (Excuses for the german error message):
    sqlplus ORA-00604: Fehler auf rekursiver SQL-Ebene 1
    sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 erweitert
    The statement I used:
    alter table werteartarchiv_pt
    add constraint werteartarchiv_pt_fk1
    foreign key (schiene, werteartadresse, merkmale)
    references werteart (schiene, werteartadresse, merkmale)
    on delete cascade
    initially deferred deferrable;
    So the problem seems to be, that Oracle needs a lot of temporary tablespace to generate the foreign key and I do not know how much and why.
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.
    2a) Is it possible to tweak the statement without using the temporary tablespace?
    2b) If it is not possible to avoid the usage of the temporary tablespace, is there a formula how to calculate the needed temporary tablespace?
    3) Is it possible to modify data in the tables while the foreign key is created or is the whole table locked during the process?
    Any help or hint is appreciated.
    Regards,
    Bjoern

    RollinHand wrote:
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.Because it's validating the data to ensure the foreign key won't be violated. If you had specified ENABLE NOVALIDATE when creating it then the existing data in the table wouldn't need to be checked and the statement should complete instantly (future data added would be checked by the constraint).
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm
    Search for "Enable Novalidate Constraint State"

  • Unable to create the temporary folder. Error 183 when starting Distiller

    New information discovered - see end of message!
    Full error message is (window title is Acrobat Distiller):
    "Unable to create the temporary folder
    Error: 183 - cannot create a file when that file already exists."
    I have no idea what file or what folder it is referring to. This is on an x86 Vista notebook and the message comes up when starting the notebook and also if you manually start Distiller 8. Updating did not help, nor did turning off the UAC, or running Distiller as Administrator. In the latter case, Distiller will open correctly, but the next time you need to use it, it fails. With the UAC turned off, the behavior is for it to show the Distiller window for a fraction of a second and close immediately. I also gave the user full rights to the C:\Program Files\Adobe folder and lower. Made no difference.
    Coincidental with this is that the PDFMOfficeAddIn.dll add-in will not enable in Word - when it is checked, and I hit OK, I get the message:
    "The connected state of Office Add-Ins registered in HKEY_LOCAL_MACHINE cannot be changed."
    All of this is going on when logged in as an administrator. I have seen folks post about this issue, but no answers that actually fiux the problem, just suggest what I have already tried. Anyone seen this one?
    The user is highly mobile, so I am not going to have a chance to work on her computer again until next week.
    NEW INFO
    I tried removing and reinstalling as administrator and the problem remains. However while trying to troubleshoot, I discovered some more details.
    The message is being thrown when acrotray.exe is started as a process in HKLM\Software\Microsoft\Windows\Current Control Set\Run and then tries to run acrodist.exe (which fails, BTW). If I don't let it run there and run acrotray,exe as administrator, then acrodist.exe runs as a process without an error. Additionally, stopping it from running in the registry, and then starting MS Word, the Acrobat add-in does load and even though there is an error thown, it still creates the PDF! I have other Vista 32 notebooks running various Acrobat versions with no problems.
    Another key thing I found out is that Acrobat started throwing the error after an HP Scanjet 8400 and its software were installed. I tried explicitly giving the user (already an administrator) full rights to the Acrobat, HP and Read IRIS directories. Did not help the problem. I have to think that there is some interaction there, but sure don't know what it is.

    what i did to eliminate that error message, i don't think it eliminated th
    e problem but now i can reboot and log in OK, was 2 things:
    i went into my system registry and unchecked to start at startup and then disavled it.
    i also had to go to each adobe icon, right click, go to properites, and than make all selections set to be administator.

  • How to create a Foreign key relationship between 2 user defined tables...

    Hi Folks,
    I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
    Any help would be highly appreciated...
    Thanks

    Hi
    1.  In the 2nd table call the field of the 1st table which is a primary key.
    2.  Give the same field and dataelement name.
    3.  Select that field and then click on the foreign key field icon which is beside Search Help button.
    4. Then give short text, and the 1st table name.
    5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
    6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
    7. Then again click on copy.
    Regards
    Haritha.

  • Creating a foreign key constraint on a synonym of table in another schema.

    Hi,
    I am having two user operapps and oper
    owner of table po_vendors is operapps ,i have created a synonym in oper with select permission.
    now i am trying to create a foreign key.
    ALTER TABLE OPS_BR_VENDORS ADD ( FOREIGN KEY (VENDOR_ID) REFERENCES PO_VENDORS (VENDOR_ID));
    the bolded po_vendors is the synonym for the table po_vendors in operapps.
    i am getting the below error message.
    SQL> ALTER TABLE OPS_BR_VENDORS ADD ( FOREIGN KEY (VENDOR_ID) REFERENCES PO_VENDORS (VENDOR_ID));
    ALTER TABLE OPS_BR_VENDORS ADD ( FOREIGN KEY (VENDOR_ID) REFERENCES PO_VENDORS (VENDOR_ID))
    ERROR at line 1:
    ORA-01031: insufficient privileges.
    i have given dba privileges to oper user.
    Please advice.

    1) You cannot create a constraint on a synonym. You have to specify a physical table (i.e. OPERAPPS.PO_VENDORS)
    2) The owner of the OPS_BR_VENDORS table will need to have the REFERENCES permission on the PO_VENDORS table granted directly (not via a role).
    Justin

  • Problem to insert id into the foreign key  php/mysql

    Hello all,
    I'm having rouble to understand the process and there is no tutorial about my problem anywhere
    I have two table:
    Table 1 (member) with id, name, phone etc
    Table2 (post) add_id, title, description, price, member_id
    I got a form to post the add and I need to insert the id of table 1 into my table 2 member_id zone
    Fisrt I did the recorset to get user id
    $colname_rsMember = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsMember = $_SESSION['MM_Username'];
    mysql_select_db($database_connect, $connect);
    $query_rsMember = sprintf("SELECT * FROM member WHERE username='".$_SESSION['MM_Username']."'")or die(mysql_error());
    $rsMember = mysql_query($query_rsMember, $connect) or die(mysql_error());
    $row_rsMember = mysql_fetch_assoc($rsMember);
    $totalRows_rsMember = mysql_num_rows($rsMember);
    This part is working and I'm able to retreive info via echo just for testing
    After this code I have my insert code
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO add (title, `description`, price, member_id) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['description'], "text"),
                           GetSQLValueString($_POST['price'], "text"),
                           GetSQLValueString($_POST['member_id'], "int"));
      mysql_select_db($database_connect, $connect);
      $Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());
      $insertGoTo = "ok.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    Do I need to include hidden field in y form?
    I'm having the same error message. Col member_id can't not be null
    Any idea what I'm doing wrong?
    Thank You!

    When someone logs in, Dreamweaver creates a session variable called $_SESSION['MM_Username']. Use that session variable to create a recordset to get the user's ID, which can then be entered into the foreign key field of the child table.
    Dreamweaver automatically puts the code for recordsets immediately above the DOCTYPE declaration, so you will need to move it above the code for the Insert Record server behavior. So, it needs to be in this order:
    Recordset to get user ID
    Insert Record for child table

  • Populate the foreign key automatically

    HI All!
    I have a form in which there are two data blocks One is emp_master and other is salary_details.I have a foreign key salary_code in Emp_master and similarly Salary_code as primary key in salary details.I have used two list item in place of Emp_id and Salary_code.I want that when I select the emp_id as 10 from the list automatically salary_code list item should get populated by 1 item in the list item.Similary the rest should follow .Please someone look into this matter it would be a gr8t help to me.
    Thanks

    Abha,
    I would not use list items for this. Instead, use a multi-record text box with a scroll bar. It looks and behaves like a t-list, but is much easier to code and manage.
    Use the datablock wizard to create the master-detail relationship. When you use the wizard, all the code will be generated for you. Then use the layout wizard, and display multiple records with scroll bars.
    BTW, it is customary to have the primary key in the master, and the foreign key in the details. In your case it is backwards.
    Also see
    http://www.oracle.com/technology/obe/obe_as_10g/bi/forms/formsmasterdetailobe.htm

  • Create a foreign key from a field that is part of a mulitple primary key

    Hi,
    i had a table named T_A, with a double primary key : (A,B)
    Then i created a table named T_B with a field : C.
    I want this field T_B.C to take only values that already exist in field T_A.A.
    So i tried to create a foreign key on my field T_B.C, pointing on the field T_A.A : an error message appeared "not possible to create a foreign key on a field that is not a primary key".
    How can i solve this....? If U have any idea, please mail me !!
    THANX very much.

    Add column A as foreign key into the table T_BHow?
    (was the question from the original poster. Adding a column to table T_B that happen to have same name as the corresponding column in table T_A would not allow you to add the foreign key).
    SQL> create table t_a (a number, b number, primary key(a, b)) ;
    Table created.
    SQL> create table t_b(a number, c number, constraint foreign key references t_a(a)) ;
    create table t_b(a number, c number, constraint foreign key references t_a(a))
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    SQL>

  • OAM Identity Asserter Provider Error:Unable to create the AccessGate entry

    Hi All,
    I have installed Oracle Access Manager and trying to protect an application deployed on weblogic application server.
    I have added the jar oamAuthnProvider in weblogic server lib mbeantypes and configured an OAM Identity Asserter Provider in myrealm. When I restart the weblogic server, I encounter the following error:
    <Error> <> <BEA-000000> <OAMAP-60516:Unableto create the AccessGate entry for identity assertion/authentication.>
    <Error> <Security> <BEA-090870> <The realm "myrealm" failed to be loaded: weblogic.security.service.SecurityServiceException
    : com.bea.common.engine.ServiceInitializationException: java.lang.RuntimeException.weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: java.lang.RuntimeException
    When I remove the following section from config.xml, the server starts fine:
    <sec:authentication-provider xmlns:ext="http://www.bea.com/ns/weblogic/90/security/extension" xsi:type="ext:oam-identity-asserterType">
    <n1:name xmlns:n1="http://www.bea.com/ns/weblogic/90/security">OAMID</n1:name>
    <n2:control-flag xmlns:n2="http://www.bea.com/ns/weblogic/90/security">REQUIRED</n2:control-flag>
    <ext:access-gate-name>MYAPP</ext:access-gate-name>
    <ext:primary-access-server>AccessServer</ext:primary-access-server>
    <ext:application-domain>MYDOMAIN.com</ext:application-domain>
    <ext:access-gate-password-encrypted>{AES}P3UIYbQpYupPs=</ext:access-gate-password-encrypted>
    </sec:authentication-provider>
    Has anyone come across this error before? Please suggest a workaround..
    Software versions being used:
    OAM 10.1.4.3
    Weblogic: 10.3.2
    Thanks
    Joe

    I am having the same problem on my WLS 10.3.4. running OSB 11g. I get the following error:
    tuning)'> <<WLS Kernel>> <> <> <1296595010528> <BEA-000000> <OAMAP-60516:Unable to create the AccessGate entry for identity assertion/authentication.>
    ####<Feb 1, 2011 1:16:50 PM PST> <Info> <Security> <WD-OR14P5A5W624> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1296595010528> <BEA-090511> <The following exception has occurred:
    com.bea.common.engine.ServiceInitializationException: java.lang.RuntimeException
         at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:365)
         at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315)
         at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257)
         at com.bea.common.engine.internal.ServicesImpl.getService(ServicesImpl.java:72)
         at weblogic.security.service.internal.WLSIdentityServiceImpl.initialize(WLSIdentityServiceImpl.java:47)
         at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:300)
         at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:222)
         at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.InitializeServiceEngine(CommonSecurityServiceManagerDelegateImpl.java:1784)
         at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealm(CommonSecurityServiceManagerDelegateImpl.java:445)
         at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.loadRealm(CommonSecurityServiceManagerDelegateImpl.java:840)
         at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealms(CommonSecurityServiceManagerDelegateImpl.java:870)
         at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initialize(CommonSecurityServiceManagerDelegateImpl.java:1030)
         at weblogic.security.service.SecurityServiceManager.initialize(SecurityServiceManager.java:881)
         at weblogic.security.SecurityService.start(SecurityService.java:142)
         at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    I looked the error number up and it says:
    OAMAP-60516: Unable to create the AccessGate entry for identity assertion/authentication.
    Cause: AccessGate instance creation failed.
    Action: See the Identity Asserter/Authenticator log for details.
    Level: 1
    Type: ERROR
    Impact: Configuration
    This seems to indication my identity assertion is incorrect. My oam authentication provider is pretty simple.
    I am using OPEN transport security so the provider config is pretty simple. I provided an AccessGate pwd, primary and secondary access gate servers and Access Gate name provided by my administrator.
    I'm not sure about what the Application Domain field refers to. Can someone provide guidance on that?

  • Unable to create the Profit center groups

    Hi,
    We have created new company codes in R3Dev and also created the
    validation rules for the same. We have assigned the Set ID's to the
    validation rules. These Set ID's gets created when profit center groups
    are created for the new company codes.
    We have transported the company code configuration settings and the
    validation rules to R3QA.
    Now in R3QA, when I try to create the profit center groups in KCH5N for
    the new company codes, it says "the group already exists".This is
    caused due to the SET ID's which also got transported along with
    validation rules. I have checked the table 'SETHEADER" which shows the
    SET ID's for the new company codes.
    Could you please a solution to resolve this issue.
    Thanks
    Rakesh

    Hi Mohan,
    Since Set Id's have moved to quality along with vaidation rules, I am to create the profit center groups, as it says the group already exists. I believe the set Id's need the master data maintained in R3Q, before they are transported. Since this is not maintained, with the transport, the data is sitting for Set Ids at the table level (Table: SETHEADER),  because of which I am to unable to create the profit center groups.
    Thanks,
    Rakesh

  • Hudson - Unable to create the home directory

    Hello, I installed tomcat and downloaded hudson.war and put it into
    /opt/tomcat/webapps/hudson.war
    I'm able to navigate to localhost:8080/hudson, but I only see this message:
    Unable to create the home directory {0}. This is most likely a permission problem.
    To change the home directory, use HUDSON_HOME environment variable or set the HUDSON_HOME system property. See Container-specific documentation for more details of how to do this.
    I've set HUDSON_HOME in a gazillion places -- yet none of them has done any good.
    Can anyone point me to a solution?
    Thanks,
    --Nate

    That indicates that Time Machine is having trouble writing to that sparse bundle.
    See #C9 and #C10 in the Time Machine - Troubleshooting *User Tip,* also at the top of the +Time Machine+ forum.

  • Disable all the foreign keys in a database

    Hy, what sql to use to disable all the foreign keys in a database and how to enable all them again. Thanks

    select * from dba_constraints where constraint_type = 'R' and status = 'ENABLED'
    ALTER TABLE table_name
    disable CONSTRAINT constraint_name;
    ALTER TABLE table_name
    enable CONSTRAINT constraint_name;
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' enable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute and save result for enable before disable
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' disable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute result for disable.

  • With WBS element unable to create the Shopping cart

    Hi,
    With WBS element unable to create the Shopping cart
    Problem description:
    Shiopping cart >Item detail > Account assignment
    A/c assignment category " WBS element", Assignment no (some no,eg 1000-2 ).System picks the G/L account and business area,unable to create the shopping cart.Getting error message that
    "The account assignment objects are defined for different business areas  "
    Did i missed anything ,please
    Thanks
    Hareesha

    Hi Hareesha,
    As Sreedhar has rightly said the issue is definitely with the correctness of the data.
    Check the assignment of WBS to the proper business area which you are using to create the shopping cart.Check your org. structure and attributes and their assignments once again.
    Neverthless some OSS notes for your reference if in case you can not able to make P.Os or the SC's / P.Os are not getting transfered to back end R/3.
    <b>Note 727897 - WBS element conversion in extended classic scenario</b>
    <b>Note 1000184 - Account assignment error when document transfer to back end</b>
    Even after validating the data if the problem still persists please explain it clearly with the errors for further help.
    Rgds,
    Teja

  • Unable to create the bluetooth virtual COM port

    Hi all
    I install BS from Toshiba and it seems ok. Bt ir desn´t work. I see all the drivers installed, system devices, etc. No Toshiba BT ports can be seen. Local com ports only show modem port. Try to create a virtual port but get a message "unable to create a bluetooh virtual port" I have a satellite m100-145. Can anyone help on this ?
    thx

    Thx for your suport.
    I decide to reinstall windows and all software. Now it works.
    The error was due to the fact that if you have BS from Microsoft (called bluetooth monitor) and you install the BS from Toshiba after that, even if you remove the BS from MS, the BS from Tos is unable to create the virtual com ports (except modem).
    I try with the latest version of BS and the problem was not solved. So if there is a previous installation of BS fom MS the BS from Tos get the message of "unable to create the bluetooth virtual com port".
    Now i fixed reinstalling SO from beginning.

  • Unable to create the portable home directory for this user

    This is driving me nuts!
    I have a network user who I can login to on any machine on the network. I want a PHD to be created on a laptop and eveytime I answer 'yes' to 'create PHD for this user' I get the "unable to create the PHD for this user" message.
    What am I doing wrong?

    I fixed this by unbinding the laptop from the od server as I had used this user previously for PHD's on this machine. Setting up the machine to bind to OD again and all is well.

Maybe you are looking for

  • Small Office Router RV08/016 or 891 -which appropriate?

    I am not certain this is correct forum, but I doubt sales techs will be able to provide requested info. I am a knowledgable newbie, but not formally trained. After 6 or 7 years, the old Linksys died and am looking to upgrade hardware and inet access.

  • Why do I keep getting an error message that my contacts have stopped working

    Sometimes, I am getting an error message that says that my contacts have quit working. Also sometimes I can't use my phone because the same error message appears when I tap the phone icon. Turning the phone off and on again sometimes helps, other tim

  • Posting block diagram in reply

     I know how to attach a snippet or vi to my posting.  I'm just wondering how do you post a block diagram .jpg image to your posting so others can see it while reading (so that it is a part of your posting along with your text).  I have seen others do

  • The graphic of Java2D is too small

    Dear all, I dunno why, but my graphic is always very very small, no matter how big I change the x and y of Point2D[]... the Line2D of (0, 0) to (0, 10) is the same as (0, 0) to (0, 1000) Should I set some Renderer for Graphic2D g2?? or use some setBl

  • Iphoto slideshow--adjusting music timing

    Hello all, Here's my issue...I'd like to add music (from Itunes) to my Iphoto slideshow. I want to adjust the timing of the song played (i.e. in Itunes I can choose a start time and end time for each song by getting info). However, when I make these