Error making Foreign Keys

Hi,
I get an error trying to create foreign keys.
The message reads "Parent keys not found".
I have the primary keys in my parent table.
Any thoughts what it could be?
Thanks,

Hi All,
Please check this:
ORA-02298 cannot validate (string.string) - parent keys not found
Cause: An ALTER TABLE ENABLE CONSTRAINT command failed because
the table has orphaned child records.
Action: Make sure that the table has no orphaned child records before issuing
an ALTER TABLE ENABLE CONSTRAINT command. For more information
about ALTER TABLE and ENABLE CONSTRAINT, see the Oracle9i SQL
Reference.
Peter D.

Similar Messages

  • $$$ Non-fatal error (1202): Foreign Key 'FCM_1_CO_OWNER(Owner_Id) reference

    Hi All,
    We are getting below fatal error while repairing the repository. and we are using MDM SP07 Patch Level 27.
    Error Message: $$$ Non-fatal error (1202): Foreign Key u2018FCM_1_CO_OWNER(Owner_Id) referencing A2i_CM_Users (UserId)u2019 is missing.
    Can  anyone help me how to resolve this issue ?
    Thanks & Regards,
    Mahesh

    Hello,
    I guess you have upgraded your system and hence you are getting this error.
    I guess some lookup table are missing the reference in this.
    But the error says NON-FATAL, please check if you are getting the same error while checking the repository.
    My suggestion would be to unmount and mount the reposiory again.
    regards,
    Abhishek

  • Using FOreign key constraints on tables in database.

    I am student and novice in the field of ORACLE and PL/SQL and Database Creation. I had created a database consisting tables and got problem while applying foreign key constraints.
    CUST_MSTR
    CREATE TABLE "DBA_BANKSYS"."CUST_MSTR"("CUST_NO" VARCHAR2(10),
    "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25), "LNAME" VARCHAR2(25),
    "DOB_INC" DATE NOT NULL,      "OCCUP" VARCHAR2(25), "PHOTOGRAPH" VARCHAR2(25),
    "SIGNATURE" VARCHAR2(25), "PANCOPY" VARCHAR2(1),      "FORM60" VARCHAR2(1));
    (CUST_NO is PRIMARY KEY, )
    -- EMP_MSTR
    CREATE TABLE "DBA_BANKSYS"."EMP_MSTR"("EMP_NO" VARCHAR2(10),
    "BRANCH_NO" VARCHAR2(10), "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25),
    "LNAME" VARCHAR2(25), "DEPT" VARCHAR2(30), "DESIG" VARCHAR2(30));
    (EMP_NO is primary key )
    --NOMINEE_MSTR
    CREATE TABLE "DBA_BANKSYS"."NOMINEE_MSTR"("NOMINEE_NO" VARCHAR2(10),
    "ACCT_FD_NO" VARCHAR2(10), "NAME" VARCHAR2(75), "DOB" DATE,
    RELATIONSHIP" VARCHAR2(25));
    (NOMINEE_NO is primary key )
    --ADDR_DTLS
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6));
    ( ADDR_NO is primary key )
    Problem: I want to apply foreign key constraints on ADDR_DTLS table so that Before inserting value in ADDR_DTLS table it must check, VALUE in ADDR_DTLS.CODE_NO must be PRESENT either in attribute value CUST_MSTR.CODE_NO or EMP_MSTR.CODE_NO or NOMINEE_MSTR.CODE_NO table .
    I applied the foreign key constraints using this syntax
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6),
    constraints fk_add foreign key CODE_NO references CUST_MSTR. CODE_NO,
    constraints fk_add1 foreign key CODE_NO references EMP_MSTR. CODE_NO,
    constraints fk_add2 foreign key CODE_NO references NOMINEE_MSTR.CODE_NO);
    (foreign key)
    ADDR_DTLS.CODE_NO ->CUST_MSTR.CUST_NO
    ADDR_DTLS.CODE_NO ->NOMINEE_MSTR.NOMINEE_NO
    ADDR_DTLS.CODE_NO ->BRANCH_MSTR.BRANCH_NO
    ADDR_DTLS.CODE_NO ->EMP_MSTR.EMP_NO
    When I applied foreign key constraints this way, its gives a error called foreign key constraints violation. (I understand that, its searches the attribute value of ADDR_DTLS.CODE_NO in all the three tables must be present then the value will be inserted. But I want, if the value is in any of the three table then its should insert the value or its gives an error.)
    Please help me out, though i put the question and i want too know how to apply the forign key in this way. and is there any other option if foreign key implementation is not pssible.

    If you are on 11g you can use ON DELETE SET NULL:
    CREATE TABLE addr_dtls
    ( addr_no          NUMBER(6)  CONSTRAINT addr_pk PRIMARY KEY
    , addr_cust_no     CONSTRAINT addr_cust_fk    REFERENCES cust_mstr    ON DELETE SET NULL
    , addr_emp_no      CONSTRAINT addr_emp_fk     REFERENCES emp_mstr     ON DELETE SET NULL
    , addr_nominee_no  CONSTRAINT addr_nominee_fk REFERENCES nominee_mstr ON DELETE SET NULL
    , addr_type        VARCHAR2(1)
    , addr1            VARCHAR2(50)
    , addr2            VARCHAR2(50)
    , city             VARCHAR2(25)
    , state            VARCHAR2(25)
    , pincode          VARCHAR2(6) );In earlier versions you'll need to code some application logic to do something similar when a parent row is deleted, as otherwise the only options are to delete the dependent rows or raise an error.
    btw table names can be up to 30 characters and don't need to end with MSTR or DTLS, so for example CUSTOMERS and ADDRESSES might be more readable than CUST_MSTR and ADDR_DTLS. Also if the Customer/Employee/Nominee PKs are generated from a sequence they should be numeric.
    Edited by: William Robertson on Aug 15, 2010 6:47 PM

  • Foreign key cannot be created for the selected field A907-MWSKZ

    Dear Guru's,
    I am having the requirement for creation of access sequence having country/Plant/vendor/tax code but during creation of condition table i am getting the error as
    Foreign key cannot be created for the selected field A907-MWSKZ.
    Anything i am missing please let me know.
    Regards,
    Umesh

    Hi Umesh,
    Actually i am also facing exactly the same problem as mentioned by you that is "Foreign key cannot be created for the selected field A769-MWSKZ ".
    I think you found some solution regarding this..can you please help me to solve it.
    Looking forward for your prompt reply..
    Thanks & Regards,
    Sandeep Sharma

  • Error when sorting foreign key fields in a view

    Hello all
    I created a view and links to other views, and then created a table. In the table I put different attributes from the view and the views it is linked to. When I click the sort ascending or descending button in a column attribute that is in the original view, everything works fine. However if I click the same arrow button for a different column, one that is in a linked view, I get this error message.
    Definition OnlineTerminalId of type Attribute is not found in ObjektiView1.
    I do not understand why this does not work. It shows the values inside these linked views just fine. I did change names of some attributes in the database but I had the problem before then, and after I changed them all back so I doubt that is the issue.
    If anyone can help I would be much obliged

    Dino2dy wrote:
    Hmm, what I did is slightly different, but what my way does is give me the ability to create forms that change automatically when I click a row in a table, which I thought would be useful. I could do it your way too but I would have to do everything again from the beginning, which is something I am trying to avoid. There should be a way to fix this problem this way, as it would be kind of stupid to be able to show the data in the table but just not be able to sort or filter by it.You can still accomplish this by relating the combined VO with your children VOs using View Links, same as what you are doing now.
    Also that view would be HUGE as it is a single table that is connected to a lot of other tables via foreign keys, so my single view would cover 10 tables.Not necessarily. You don't have to include all Entities in your combined VO - just those that you want their attributes displayed on your table.
    Nick

  • Ora-2270 Error while adding foreign key constraint on top a view

    While adding a constraint, referencing a foreign key column from a view raises error. However, it works fine over a table.
    Here's the sample script:
    create table t_temp (
    sample_id number,
    text varchar2(40))
    alter table t_temp add constraint temp_pk
    primary key (sample_id);
    create view tempvw as select sample_id,text from t_temp;
    create table t_sample (
    uniq_id number,
    sample_id number,
    sample_text varchar(40));
    =========
    ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp
         FOREIGN KEY (sample_id) REFERENCES t_temp (sample_id);
    This works fine.
    =========
    ==============
    The following raises ERROR....
    ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp1
         FOREIGN KEY (sample_id) REFERENCES tempvw (sample_id);
    Error starting at line 1 in command:
    ALTER TABLE t_sample ADD CONSTRAINT FK_sample_temp1
         FOREIGN KEY (sample_id) REFERENCES tempvw (sample_id)
    Error report:
    SQL Error: ORA-02270: no matching unique or primary key for this column-list
    02270. 00000 - "no matching unique or primary key for this column-list"
    *Cause:    A REFERENCES clause in a CREATE/ALTER TABLE statement
    gives a column-list for which there is no matching unique or primary
    key constraint in the referenced table.
    *Action:   Find the correct column names using the ALL_CONS_COLUMNS
    catalog view

    What exactly are you trying to accomplish by having a
    referential integrity constraint on a view (which is
    not allowed). PKs and FKs are allowed on views. DISABLE NOVALIDATE is the only allowed state for them. View constraints are used for query rewriting: http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/qradv.htm#sthref1457
    Regards,
    Dima

  • Foreign key errors in sql plus

    Hello, im pretty new to sql and i am stuck on a project in my database management class and i was wondering if anyone can help us out. I don't know if it would be easier to send what i've done or just post the error so if anyone could help it will be appreciated.
    This is one part of the sql
    CREATE TABLE PREREQUISITE_T
         (COURSECODE                VARCHAR2(10)NOT NULL,
         PREREQUISITECODE          VARCHAR2(20),
    PRIMARY KEY (COURSECODE),
    PRIMARY KEY (PREREQUISITECODE),
    FOREIGN KEY (COURSECODE) REFERENCES COURSE_T(COURSECODE),
    FOREIGN KEY (PREREQUISITECODE));
    INSERT INTO PREREQUISITE_T VALUES ('23131', '3213');
    INSERT INTO PREREQUISITE_T VALUES ('23541', '4213');
    INSERT INTO PREREQUISITE_T VALUES ('23251', '3413');
    INSERT INTO PREREQUISITE_T VALUES ('56131', '3513');
    INSERT INTO PREREQUISITE_T VALUES ('75431', '3613');
    INSERT INTO PREREQUISITE_T VALUES ('45631', '3813');
    INSERT INTO PREREQUISITE_T VALUES ('65461', '3913');
    INSERT INTO PREREQUISITE_T VALUES ('45351', '5413');
    the error i get is
    ERROR at line 1:
    ORA-02298: cannot validate (STUDENT.SYS_C003016) - parent keys not found
    It works fine without the primary keys but when i put in foreign keys it is all messed up. If there a a tutorial or anyone could take a look at the rest of the code i can send it out. Any help is appreciated.

    probably u had given the column value not exists in the reference table.
    see the example
    create table tst(x number ,y number);
    alter table tst add constraints pk_x primary key(x);
    create table tst1(x number, y number);
    alter table tst1 add constraints fk_x foreign key(x) references tst(x);
    SQL> insert into tst values(&x,&y);
    Enter value for x: 1
    Enter value for y: 2
    old 1: insert into tst values(&x,&y)
    new 1: insert into tst values(1,2)
    1 row created.
    SQL> /
    Enter value for x: 2
    Enter value for y: 3
    old 1: insert into tst values(&x,&y)
    new 1: insert into tst values(2,3)
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into tst1 values(&x,&y);
    Enter value for x: 2
    Enter value for y: 1
    old 1: insert into tst1 values(&x,&y)
    new 1: insert into tst1 values(2,1)
    1 row created.
    SQL> /
    Enter value for x: 5
    Enter value for y: 6
    old 1: insert into tst1 values(&x,&y)
    new 1: insert into tst1 values(5,6)
    insert into tst1 values(5,6)
    ERROR at line 1:
    ORA-02291: integrity constraint (SHFLDEV.FK_X) violated - parent key not found

  • Error when adding Foreign Key

    Hi,
    Problem:
    When trying to add a Foreign Key via Edit Table | Foreign Key tab an error is thrown
    Error:
    "ORA-00942: table or view does not exit", Vendor code 942
    SQL Developer Generated DDL:
    ALTER TABLE "CNArticlesCODES"
    DROP CONSTRAINT "CNArticlesCODES_FK1"
    ALTER TABLE "CNArticlesCODES"
    ADD CONSTRAINT "CNArticlesCODES_FK1" FOREIGN KEY
    "ID"
    ) REFERENCES CNArticlesDATA
    "ID"
    ) ENABLE
    My work around:
    table name next to REFERENCES command in double quotes
    ALTER TABLE "CNArticlesCODES"
    ADD CONSTRAINT "CNArticlesCODES_FK1" FOREIGN KEY
    "UID"
    ) REFERENCES "CNArticlesCODES"
    "UID"
    ) ENABLE
    SQL Developer 1.0.0.15.57 on Windows XP SP2
    Oracle Database 10g Enterprise Edition Release 10.2.0.10 (Eval Lic) on Windows 2003 Web Edition 32 bit
    The 2 tables in this example where generated by MS DTS tool while importing data. This issue is not present when performing the above action on 2 tables generated using SQL Developer.
    I'm no database expert and new to Oracle (R&D stage of SQL Server to Oracle migration). So can some body tell me/point me at docs that explains what's going on here with the table names.
    Thanks

    Hopefully someone from oracle will see this and log it as a bug. If that doesn't happen and you have a support license, you can open up a ticket with them directly.
    As an aside.. if you are daring enough, the template for that is stored in one of the jars in an xml file. You can always edit it and add the quotes. Or..and you don't want to hear this.. you may want to rename everything to uppercase. It would hurt now, but could end up saving you time down the road. (adding quotes to every query is a pain)
    Eric

  • Foreign Key Error Message ORA - 01430

    I have a table name LSU_INTER_RESOURCES_T. I would like to add a foreign key constraint with the following command:
    alter table lsu_inter_message_t
    add constraint inter_message_id_fk
    inter_request_id REFERENCES lsu_inter_requests_t(inter_request_id) ON DELETE CASCADE;
    The system returned the error message:
    ORA - 01430: column being added already exists.
    if I drop the column inter_request_id I will lose data and when I create the constraint it places the column at the end of the table. Losing data is not an issue now because the table has no data but down the line I can see that this will be a real real hassle.
    I would like to have the foreign key column defined in the sequence I chose when I designed the table layout. That is to say I want all of the key columns placed at the begining of the table row layout.
    Can I move the column after I define it and how is this done? Is this a 10g feature?
    Thank you, Ned

    Try
    alter table lsu_inter_message_t
    add constraint inter_message_id_fk
    foreign key(inter_request_id ) REFERENCES lsu_inter_requests_t(inter_request_id) ON DELETE CASCADE;

  • EJB-QL (foreign key)- error

    hi everyone. i am stuck, cheked everything and don't know where to look. i hope someone will help me. i use websphere 5.0
    i have 2 cmp entity ejb with one-many relationship between them. I wrote QL query using foriegn key. when i generate EJB-RDB mapping the error appears in TASK saying " myTable o does not have a field myforeignkey". when i click on tast it opens ejb dep...descriptor. i check descriptor and foreign key is there.
    where should i look? when i run validation before mapping generation it doesn't produce any error.

    i am new to J2ee and i let websphere to generate all description code. I spend 4 hours looking for this error and i just can'f fix it. it looks fine to me. can you have a look? i know the code is big. if you get extra time then help me. i cut it down. there is two entity beans each with one attribute. order id has second attribute as foreign key -generatorhome_id.
    the full error is like this:
    WQRY0036E:OrderId o does not have a field generatorhome_id. when i click on it takes me to my created <query-method> findByFor
    please help if have time. the code should be straight forward. if you want me to simplify code so you can better understand then let me know.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar id="ejb-jar_ID">
         <display-name>EJB</display-name>
         <enterprise-beans>
              <entity id="OrderId">
                   <ejb-name>OrderId</ejb-name>
                   <local-home>com.ibm.pbw.ejb.OrderIdLocalHome</local-home>
                   <local>com.ibm.pbw.ejb.OrderIdLocal</local>
                   <ejb-class>com.ibm.pbw.ejb.OrderIdBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>com.ibm.pbw.ejb.OrderIdKey</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>OrderId</abstract-schema-name>
                   <cmp-field id="CMPAttribute_1088406971782">
                        <field-name>ind</field-name>
                   </cmp-field>
                   <cmp-field>
                        <description>Generated to support relationships. Do NOT delete.</description>
                        <field-name>generatorhome_id</field-name>
                   </cmp-field>
                   <ejb-local-ref id="EJBLocalRef_1088406284143">
                        <ejb-ref-name>ejb/GeneratorHome</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.ibm.pbw.ejb.GeneratorHomeLocalHome</local-home>
                        <local>com.ibm.pbw.ejb.GeneratorHomeLocal</local>
                        <ejb-link>GeneratorHome</ejb-link>
                   </ejb-local-ref>
                   <query>
                        <description></description>
                        <query-method>
                             <method-name>findByFor</method-name>
                             <method-params>
                                  <method-param>int</method-param>
                             </method-params>
                        </query-method>
                        <ejb-ql>select object(o) from OrderId o where o.generatorhome_id = ?1</ejb-ql>
                   </query>
              </entity>
              <entity id="GeneratorHome">
                   <ejb-name>GeneratorHome</ejb-name>
                   <local-home>com.ibm.pbw.ejb.GeneratorHomeLocalHome</local-home>
                   <local>com.ibm.pbw.ejb.GeneratorHomeLocal</local>
                   <ejb-class>com.ibm.pbw.ejb.GeneratorHomeBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>com.ibm.pbw.ejb.GeneratorHomeKey</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>GeneratorHome</abstract-schema-name>
                   <cmp-field id="CMPAttribute_1088406971792">
                        <field-name>id</field-name>
                   </cmp-field>
                   <ejb-local-ref id="EJBLocalRef_1088406284153">
                        <ejb-ref-name>ejb/OrderId</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.ibm.pbw.ejb.OrderIdLocalHome</local-home>
                        <local>com.ibm.pbw.ejb.OrderIdLocal</local>
                        <ejb-link>OrderId</ejb-link>
                   </ejb-local-ref>
              </entity>
         </enterprise-beans>
         <relationships>
              <ejb-relation>
                   <description></description>
                   <ejb-relation-name>GeneratorHome-OrderId</ejb-relation-name>
                   <ejb-relationship-role id="EJBRelationshipRole_1088406971782">
                        <ejb-relationship-role-name>generatorhome</ejb-relationship-role-name>
                        <multiplicity>Many</multiplicity>
                        <relationship-role-source>
                             <ejb-name>OrderId</ejb-name>
                        </relationship-role-source>
                        <cmr-field>
                             <cmr-field-name>generatorhome</cmr-field-name>
                        </cmr-field>
                   </ejb-relationship-role>
                   <ejb-relationship-role id="EJBRelationshipRole_1088406971783">
                        <ejb-relationship-role-name>orderid</ejb-relationship-role-name>
                        <multiplicity>One</multiplicity>
                        <relationship-role-source>
                             <ejb-name>GeneratorHome</ejb-name>
                        </relationship-role-source>
                        <cmr-field>
                             <cmr-field-name>orderid</cmr-field-name>
                             <cmr-field-type>java.util.Collection</cmr-field-type>
                        </cmr-field>
                   </ejb-relationship-role>
              </ejb-relation>
         </relationships>
    </ejb-jar>

  • Mapping error at deployment with foreign key data rule

    I have created data rules for enabling foreign key constraints. There are 4 foreign key constraints on the fact table.
    For the 1st foreign key ... its a single key match key1 on table 1
    For the others, its a composite key .. key1 and key2 on table 2
    key1 and key3 on table 3
    key1 and key4 on table 4
    When I implement with the single key foreign key constraint the mapping works fine. But when I apply the other foreign key data rules for composite keys, I get the following message while deploying ....
    M_CNT Create Warning ORA-06550: line 209, column 3:
    PL/SQL: ORA-00909: invalid number of arguments
    M_CNT Create Warning ORA-06550: line 520, column 65530:
    PL/SQL: SQL Statement ignored
    M_CNT Create Warning ORA-06550: line 56, column 65530:
    PL/SQL: SQL Statement ignored
    M_CNT Create Warning ORA-06550: line 673, column 3:
    PL/SQL: ORA-00909: invalid number of arguments
    The data rule setup done is type Referential
    Specify the number of attributes in row relationship - 2
    Specify the referencing cardinality of row relationship
    Minimum Count 1 Maximum Count n
    Specify the referenced cardinality of row relationship
    Minimum Count 1 Maximum Count n
    What is it that I am doing wrong ?
    Any suggestions. Help !!!!
    Regards,
    AW

    Hi AW,
    How can I overcome this situation ?The best solution as suggested by Jörg is use of surrogate keys.
    For every production key (composite or single) generate a corresponding surrogate key using sequence operator in staging area.
    This will not just solve your problem but it will be faster also (the joins will be faster with system-generated sequence numbers),
    In a data warehouse use of production keys as primary key for linking with (foreign key) is not recommended, keep the production keys as additional attributes.
    Regards,

  • Foreign Key Error script Generation

    here is
    CREATE table script
    create table employee_history
    (empl_id_hist number,
    empl_name varchar2(20)
    alter table employee_history
    add constraint emp_TO_empHIST foreign key (empl_id_hist)
    references employee (empl_id);
    Create table employee
    (empl_id number,
    ename varchar2(20));
    some empl_id_hist values not in Master table employee.
    now Foreign Key disabled.
    for checking not valid empl_id_hist ids
    I am trying to generate a script like this using Dynamic SQL.
    select unique empl_id_hist from employee_history
    where empl_id_hist not in (select empl_id from employee);
    but i am getting same Column empl_id_hist (instead of empl_id ) in Subquery too
    i.e
    select unique EMPL_ID_HIST from employee_history
    where EMPL_ID_HIST not in (select EMPL_ID_HIST from employee);
    DECLARE
    CNT NUMBER := 0;
    V_SQL_STR VARCHAR2(255);
    v_col_name VARCHAR2(255);
    v_ind CHAR(1);
    v_sql_where VARCHAR2(255);
    CURSOR C1 IS
    SELECT DECODE(c.position, 1, b.table_name, ' ') MASTER_TAB,
    DECODE(c.position, 1, a.table_name, ' ') CHILD_TAB,
    DECODE(c.position, 1, a.constraint_name, ' ') constraint_name,
    c.column_name colname
    from dba_constraints a,dba_constraints b, dba_cons_columns c
    where a.status = 'DISABLED'
    AND a.constraint_type = 'R'
    AND a.constraint_name = c.constraint_name
    and a.r_constraint_name = b.constraint_name (+)
    order by b.table_name, a.table_name, c.position;
    CURSOR c2(cons_name VARCHAR2) IS
    SELECT column_name FROM User_Cons_Columns
    WHERE constraint_name = cons_name
    ORDER BY column_name;
    BEGIN
    FOR R1 IN C1 LOOP
    v_col_name := '';
    BEGIN
    FOR r2 IN c2(r1.constraint_name) LOOP
    cnt := cnt + 1;
    IF cnt <= 1 THEN
    V_ind := 'y';
    V_SQL_sTR := 'SELECT UNIQUE A.'||R1.colname ||' FROM ' ||R1.CHILD_TAB ||' A' || chr(10);
    V_SQL_STR := V_SQL_STR ||'WHERE A.'||R1.colname ||' NOT IN ';
    V_SQL_STR := V_SQL_STR || '(SELECT B.'|| R1.colname ||' FROM ' || R1.MASTER_TAB ||' B);' ||chr(10);
    V_COL_NAME := V_COL_NAME || R2.COLUMN_NAME ||',';
    v_Sql_where := 'WHERE A.'||R2.COLUMN_NAME ||' = B.' || R2.COLUMN_NAME ||chr(10);
    ELSE
    v_ind := 'n';
    v_Sql_where := v_Sql_where || 'AND A.'||R2.COLUMN_NAME ||' = B.' || R2.COLUMN_NAME ||chr(10);
    V_COL_NAME := V_COL_NAME || R2.COLUMN_NAME ||',';
    END IF;
    END LOOP;
    v_sql_where := v_sql_where ||');';
    cnt := 0;
    END;
    IF v_ind = 'y' THEN
    DBMS_OUTPUT.PUT_LINE(V_SQL_sTR);
    ELSIF v_ind = 'n' THEN
    v_sql_str := '';
    v_col_name := SUBSTR(v_col_name,1,LENGTH(v_col_name) - 1) || '';
    V_SQL_STR := 'SELECT UNIQUE '|| V_COL_NAME ;
    V_SQL_STR := V_SQL_STR || ' FROM ' || R1.CHILD_TAB || ' A'|| CHR(10);
    V_SQL_STR := V_SQL_STR || 'WHERE NOT EXISTS ( '||CHR(10);
    V_SQL_STR := V_SQL_STR || 'SELECT 1 FROM ' ||R1.MASTER_TAB ||' B';
    DBMS_OUTPUT.PUT_LINE(V_SQL_STR);
    DBMS_OUTPUT.PUT_LINE(V_SQL_WHERE);
    DBMS_OUTPUT.PUT_LINE('');
    END IF;
    v_ind := '';
    END LOOP;
    END;
    thanks in advance

    That's because with this cursor
    CURSOR c2(cons_name VARCHAR2) IS
    SELECT column_name FROM User_Cons_Columns
    WHERE constraint_name = cons_name
    ORDER BY column_name;You assume that the column names are the same in both tables. You will need to read from user_cons_columns twice, once with the fk constraint name, once with the pk constraint name.
    SQL> create table parent (id number constraint parent_pk primary key) ;
    Table cr&eacute;&eacute;e.
    SQL> create table child (child_id number,
      2                      constraint child_fk1 foreign key (child_id)
      3                      references parent (id)
      4                     ) ;
    Table cr&eacute;&eacute;e.
    SQL> select
      2     a.column_name as parent_column_name,
      3     b.column_name as child_column_name
      4   from
      5     user_cons_columns a, user_cons_columns b
      6   where
      7     a.constraint_name = 'PARENT_PK'
      8     and b.constraint_name = 'CHILD_FK1'
      9     and a.position = b.position
    10   order by
    11     a.position ;
    PARENT_COLUMN_NAME             CHILD_COLUMN_NAME
    ID                             CHILD_ID

  • SQl*Modeler - foreign key amendment error

    SQl*Modeler 2.0.0 Build 584 (Windows)
    Oracle 10.2.0.4 Solaris
    If I change an existing foreign key to simply change the delete rule (from say CASCADE to RESTRICT) it changes in memory just fine. If I generate the DDL the change has happened and I get the expected DDL.
    However, I then save the model, exit SQL*Modeler, start SQL*Modeler and check the foreign key the change has been lost.
    I can workaround this by changing the name of the foreign key and the change is saved correctly. Feature ?
    Ian

    Hi Ian,
    I logged bug for that.
    You can use foreign key dialog to do that change without need to change the name - just double-click on FK line or presentation in the browser.
    Philip

  • ORA-02292: integrity constraint - foreign key delete

    I am getting the above error message when attempting to delete an entry with a foreign key constraint. I have the standard delete button and the standard DML process for inset, update, delete, and a page validation conditioned on the delete button for EXISTS with the following code:
    select 1 from dual
    where (select count(*) from mdeccommitments
    where producer = :P25_COREID
    and receiver = :P25_COREID) = 0
    and (select count(*) from mdecbriefcal
    where primarytarget = :P25_COREID
    and primaryowner = :P25_COREID) = 0
    This code works in SQL directly. However, when I try to run this, I do not get the inline error associated with the validation routine, I just get the popup for the delete and then the very user-unfriendly Oracle error, almost as if the validation wasn't there. I tried removing the popup associated with the delete button, but it did not make a difference.
    I want to provide a friendly intercept and return. I do not want to cascade the delete. What am I missing here?
    Thanks.
    Gillian

    Thanks Varad, by running the debug, I realized I misinterpreted what the validation did - I had used EXISTS instead of NOT EXISTS. Making this change resulted in the correct processing. Being a newbie, I wasn't sufficiently familiar with the debug option to think about it.

  • Foreign Key Problem.. plz help urgently

    I have a Z table having these fields....
    MANDT     MANDT
    GSBER     GSBER (primary key also)
    HBKID     HBKID
    Foreign key is defined for GSBER (taken from TGSB table)
    Check table is defined both for GSBER and HBKID..
    i have created a table maintainence generator also..
    my Requirement is that... When i am entering value in   the table...
    for One value of GSBER there can be only one value of HBKID
    basically a  1 is to  1  relationship...
    i wil give an example..
    GSBER    HBKID
    120           555     ( Right)
    120           545     (not Allowed)
    343           555     (not allowed)
    ps: I have tried making the HBKID also as primary key... but then it is accepting values which are null. so i dont think thts  right...
    How can i use cardinality in this case.... If that is the solution?
    thanks
    Ankit

    Hi Ankit,
    1> Make the field GSBER as mandatory in overview and single screen in table   maintainance->double click the screen numbers->element list->special attr.->make input as required so that <b>null value</b> won't be accepted.
    2> Create a event in table maintainance ( <b>creating a new entries</b> )
    3> write an select query to check whether this value already exist in table in the fields GSBER, HBKID.
                 SELECT GSBER HBKID INTO WS_ZTABLE
                 FROM ZTABLE
                 WHERE GSBER EQ ZTABLE-GSBER OR
                       HBKID EQ ZTABLE-HBKID.
    4> IF any values found then display 'error message'
               else accept the entries.
    I think this will solve ur problem
    Regards,
    Nithya

Maybe you are looking for

  • "Java file" & "Jsp file" compilation issues in Eclipse

    Hi, Eclipse Question 1: I have set the value for preference->java->Installed JREs as : j2re1.4.2_07 not to jdk When I write a java file, its compiling, how? From where its using "javac" exe file for compilation. Question 2: Whereas in prefrence->Tomc

  • Unknown error (4251)

    Hi, I have been doing a lot of research all night on my problem and I see that not many people know how to get past it. The one person who posted that their problem was solved by using this forum. Anyway, when I tried to burn an audio book that I dow

  • EXE on a CD won't launch a PDF

    Hi - When building and testing my project I was able to launch PDFs in a separate browser window. The PDFs are in a folder within the project. When I burn the project on a CD, the Mac Projector opens Acrobat Reader in a Safari window and shows the PD

  • Updating my iPod

    Okay, so I'm off campus right now and I don't have my computer with me. I want to update my iPod through my parent's computer so it stops telling me to update... If I update will I lose all of my music files that I have on my iPod? I do NOT have them

  • Collective entry of Measurement document

    Dear Expert,                       We running the collective entry list process through IK34 for measurement document.i would like to inform you that we have three measuring point(A,B,C) attached in particular equipment(Z).but we put only two entries