Error with forign key constraints

hi
I have a .sql file which contains about 180 tables scripts . TO disable the contraints i ran the below script first
begin
for v in (select constraint_name, table_name from user_constraints where constraint_type = 'R')
loop
     execute immediate
     'alter table ' || v.table_name || ' disable constraint ' || v.constraint_name;
end loop;
end;
and then the .sql file by giving @filename.sql .Some of the scripts are getting executed but the one's having forign key references it is showing containt error foreign key check. but when i ran the above script ie the one to disable the foreign key check again and then ran each of these table scripts which showed error before manually it gets executed .why is this so? can anyone help me in solving this problem
Thanking you in advance
Dinny

I have a .sql file which contains table scripts and i some of these tables there is foreign key referencesing other tables so when i am ruuning the script it is showing such tables(ie the tables that i am refering to) is not existing for eg below is one of the script from the .sql file
create table t_system_groups (
group_id NUMBER(11) not null,
group_name VARCHAR2(255) not null,
group_desc VARCHAR2(255),
parent_id NUMBER(11) default '0',
full_path VARCHAR2(255) default NULL,
CONSTRAINT pk_group_id_t_system_groups PRIMARY KEY (group_id),
CONSTRAINT uk_group_name_t_system_groups UNIQUE (group_name),
CONSTRAINT fk_t_system_groups FOREIGN KEY (parent_id) REFERENCES t_system_groups (group_id) ON DELETE CASCADE
Since i have run the script for disabling the constraints before running the .sql file then why is it showing such as error. also showing errors with drop table having references
for eg:
SQL> begin
2 for v in (select constraint_name, table_name from user_constraints where constraint_type = 'R'
3 loop
4 execute immediate
5 'alter table ' || v.table_name || ' disable constraint ' || v.constraint_name;
6 end loop;
7
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> drop table t_system_groups;
drop table t_system_groups
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys
Regards
dinny

Similar Messages

  • UML to DB Diagram Transformation: Error with primary key in MySQL

    Hi,
    I am new in JDeveloper and I am following an Oracle tutorial to transform an UML class Diagram into a DB diagram http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_81/jdtut_11r2_81_2.html.
    My idea is to create a real DB form this DB diagram.
    I am now trying to transform a simple UML class into a DB class. I want to use a MYSql transformation and I want to define my self primary key, so I done the following steps:
    - Create a UML class diagram
    - Create a class "Person" with an attribute "ID:String"
    - Define a Database profile
    - Define a stereotype in my primary key attribute where:
    + I have checked box "Is Primary Key?"
    + I set in property "Data Type MySql Database Server) to "Varchar(20) NOT NULL"
    Now when I try to do the transfromation:
    - I set option "UML to Offline Database Objects"
    - I create a new Offline DB which emulates a "MySQL Dataserver 5.x"
    - When I click "Finish" I become a popup error which says: "*Invalid name PERSON_PK. Must use `PRIMARY`for MYSQL Primary Key*"
    I don't really now how to solve this problem...I have tried all I have read and google but nothing works...I think I am forgotting something basic but I do not know what!
    I am working with JDeveloper 11.1.2.1.0 and with MySql Server 5.5.
    Thanks in advance!

    Result of that table issue fix is that migration went ahead, finished both uptime and downtime run. Now i am trying to login to SAP and system is unable to log me in as DOKTL doesnt exist at all
    But i see another table called DTELDOKTL in HANA, which same as DOKTL but no entries in it.
    I have created a message to SAP , But what should i be doing now ?
    Can i create this table in HANA ?
    Can i do export/import of table ? Table structure should be there in system already for this option i guess.
    Would i be able to replicate this table if i setup SLT ?
    Please advise
    C Mon Sep  8 11:02:30 2014
    C  *** ERROR =>   prepare() of C_0341, rc=1, rcSQL=259
    [dbsdbsql.cpp 1397]
    C  {root-id=00505680721D1EE48DE09241702FF193}_{conn-id=00000000000000000000000000000000}_0
    C  *** ERROR => PREPARE C_0341 on connection 0, rc=259
    [dbslsdb.cpp  9138]
    C  SQLCODE    : 259
    C  SQLERRTEXT : invalid table name:  Could not find table/view DOKTL in schema SAPECS: line 1 col 97 (at pos 96)
    C  sc_p=7f28f48cfac8,no=341,idc_p=7f28f3f87388,con=0,act=0,slen=254,smax=256,#vars=5,stmt=7a45980,table=DOKTL
    C  stmtid = <0/SAPMSYST                                /50334994/20140907170329>
    C  SELECT "ID" , "OBJECT" , "LANGU" , "TYP" , "DOKVERSION" , "LINE" , "DOKFORMAT" , "DOKTEXT" FROM "DOK\
    C  TL" WHERE "LANGU" = ? AND "ID" = ? AND "OBJECT" = ? AND "TYP" = ? AND "DOKVERSION" = ? ORDER BY "ID"\
    C   , "OBJECT" , "LANGU" , "TYP" , "DOKVERSION" , "LINE" ;
    B  ***LOG BZA=> table DOKTL does not exist on database R/3 [dbdbslst     3580]
    M  ThPerformDeleteThisSession: switch of statistics
    D  GuiStatus clear generate inline ts >20140908030105,195<
    M  ***LOG R47=> ThResFreeSession, delete () [thxxmode.c   1078]
    M  *** WARNING => ThrtGuiDeleteScreen: rscpGetUserLoginLang failed (128), use system language [thrtGuiHandl 469]
    Thanks,
    GR

  • SM30 - Deleting a record with Foriegn Key Constraints

    I have a two custom tables ZCCED_STATUS and ZCCED_COSTITEM. 
    ZCCED_COSTITEM has a status column with a foriegn key to a (PK) status record in ZCCED_STATUS.
    I have generated table maintenance objects for the table ZCCED_STATUS.
    When I go to SM30 and maintain the table ZCCED_STATUS I can select a status record and delete it. (still ZCCED_COSTITEM records using that status)
    Is there any way that SM30 can warn or stop a user from deleting a ZCCED_STATUS record when there are child records in the ZCCED_COSTITEM table?
    Regards,

    Create a maintenance view , link both tables and generate a table maintenance for the maintenance view . it will work.

  • 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

  • Problem with Tab key

    Hi all,
    I have a swing appication run JDK1.3.1. I try to run on JDK1.4.2 is OK, but TAB key isn't available from this component to other component.
    Any suggestion would be appreciated.
    Thanks in advance.

    Component can JButton, JTextField, JComboBox...
    Not at all Dialogs error with tab key, but when open Dialog that is'nt available with tab key then next dialogs is'nt available too althought they available with tab key.

  • HSU65: Business VAPI's and domain key constraints

    Hi,
    A question about the utlity 'Create view definition based on
    table definition'.
    When I create a business VAPI with a lookup table which is
    related to the base table by a domain key constraint, the lookup
    table is joined in the view definition, but no join condition is
    created in the where clause of the domain key constraint.
    Is there a newer version of the utility that deals with domain
    key constraints?
    Regards,
    Michiel

    Unfortunately, we don't support this feature in the utility. You should be able to work around this by adding the
    where clause manually. I've documented this as an enhancement request.
    Regards,
    Lauri

  • Error with Links if using x3 primary keys

    Hi Folks:
    Here is the error code I'm receiving:
    ORA-01422: exact fetch returns more than requested number of rows
    Unable to fetch row.
    Background: I am using Application Express 3.2
    All of the pages I have created that rely on x2 primary keys (first_name, last_name) work fine.
    I have a table that has x3 primary keys: Table is called "time_off_awards". The x3 primary keys are: last_name, first_name, approval_date.
    I created a report that works properly and lists the awards for each person (each person can receive more than one award-on different dates).
    I also created an edit link that works properly IF *(only if)* each individual has only one award. If the individual has more than one award then I get the error above. When I set up the link I used all three keys. The x3 PK's should uniquely identify each row, but if the same last name/first name appear more than once (that is if the person has more than one award) I get the error. I thought at first maybe it was just not reading the 3rd key/part of the link (approval_date), but it shows properly if you move your cursor over the edit link.
    Here is a link to a screen pic of how I have my link set in Apex:
    [http://www.wczone.com/link_settings.gif]
    Here is a link to a pic of the report with some info:
    [http://www.wczone.com/report_link.gif]
    If needed, here is my table info:
    CREATE TABLE PERSONNEL.TIME_OFF_AWARDS (
    LAST_NAME VARCHAR2(40) NOT NULL,
    FIRST_NAME VARCHAR2(25) NOT NULL,
    APPROVAL_DATE DATE NOT NULL,
    HOURS_OFF NUMBER(3),
    CITATION VARCHAR2(1500),
    /* Keys */
    PRIMARY KEY (LAST_NAME, FIRST_NAME, APPROVAL_DATE),
    /* Foreign keys */
    CONSTRAINT TOA_PERSONNEL
    FOREIGN KEY (LAST_NAME, FIRST_NAME)
    REFERENCES PERSONNEL.MARC_PERSONNEL(LAST_NAME, FIRST_NAME)
    TABLESPACE PERSONNEL;
    Thanks for any help, I've tried looking at a couple of Apex books, but they didn't help much.
    Matt
    Edited by: user10495310 on Mar 4, 2009 8:21 AM

    Thank you everyone for the help and information you gave to me.
    Your ideas and advice helped me to think through the issues involved.
    The way i actually found to work around this issue was a little different.
    What I did was the following (which may only be usable with empty tables. If its possible to create a new column with a sequence and trigger on a table that already contains data it should work also):
    1. I removed the current PK's that were currently set.
    2. I added a single, unique PK (that used a sequence and trigger to automatically increment) to the table as was suggested in this thread and other APEX forum threads.
    3. I changed the link on the report so that it used the new PK, and also changed the PK used on the forms (under Processes - both the page rendering and page processing processes).
    The Difference:
    4. Next I changed the table (not by using APEX, but directly) from using the automatically generated ID as the PK, back to using the compound PK (x3 keys). I then added an constraint to make sure that the automatically generated column was unique. So now I have the compound PK that my supervisor wants us to use, and I'm able to use a unique, automatically generated key for APEX to use.
    I found also that if you already have a column that uses a unique/auto-generated key you can still use it with APEX without switching keys around.
    1. I added the new column to the sql in the reports source section so that the new column was searched (and then used 'hidden' so it wouldn't be displayed on the report users would see).
    2. You can still add the unique key under the processes on the form that is being linked too under the Primary key tabs. If its not a PK it won't show up in the pop up which is to the right of "Item Containing Primary Key Column Value" but it can be entered manually (i.e. p23_AUTO_ID) and it will work fine. You would also need to edit your form so that the auto ID that is being passed from the report is part of the form - but hidden if desired).

  • Unable to enforce Primary Key constraint with my code

    Hi Guys
    I have a table that contains 2 columns: code and description (defined as not null). I am using oracle forms 10g, if I inset a new row both the columns: code and description should have data e.g. code: 001 and description: Main Store...
    So on forms I have an on-update trigger on block level that handles the error messages but if the user has to update the description this trigger blocks him because the value for the code i.e. 001 is already on the database but if I remove the piece of code (the first IF block on my code together with a cursor and the entire declaration section)then the primary key constraint is violated: the code is as follows:
    declare
    v_store_code store_types.code%type;
    cursor store_codes is
    select a.code
    from store_types a
    where a.code = :b1.code;
    begin
    open store_codes;
    fetch store_codes into v_store_code;
    if ( store_codes%found ) then
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');
    close store_codes;
    raise form_trigger_failure;
    end if;
    close store_codes;
    if :b1.code is not null and :b1.description is null then
         message('If the Store Code has been captured, then the Store Description must be captured!');
         message('If the Store Code has been captured, then the Store Description must be captured!');
    raise form_trigger_failure;
    end if;
    if :b1.description is not null and :b1.code is null then
         message('If the Store Description has been captured, then the Store code must be captured!');
         message('If the Store Description has been captured, then the Store code must be captured!');
         raise form_trigger_failure;
    end if;
    exception
              when others then
                   message(sqlerrm);
                   raise form_trigger_failure;
    end;
    My main intention here is: the user should be able to update the description field and save the changes without violating primary key on the column: code ...... please help me guys...

    ICM
    Sir as far I could understand , your problem is that your wanna allow the end users to update the Store_description , and Store_code..
    So on forms I have an on-update trigger on block level that handles the error messages but if the user has to update the description this trigger blocks him because the value for the code i.e. 001 is already on the databaseif it's right then why don't you have unique key constraints Store_description?
    alter the tables and apply unique key constraint...
    and no need to write this code
    f :b1.code is not null and :b1.description is null then
    message('If the Store Code has been captured, then the Store Description must be captured!');
    message('If the Store Code has been captured, then the Store Description must be captured!');
    raise form_trigger_failure;
    end if;because as you mentioned
    code and description (defined as not null)if they are already under not null constraints then no need to handle this in coding..
    he/she must be able to change the description and save the changes without affecting the code i.e.:Sir I think updation in records can only be performed when the forms is in query mode e.g execute query, have all/desired records and then make changes
    (1)description is in unique key constraint it can't be duplicated ..
    (2)code is PK it can never be duplicated...
    for this I would suggest you to have a update button on forms , when-button-pressed trigger sets property of block (update_allowed, property_true);
    and check the code of unique key violation code from oracle form's help , when that error code raise up you can show those message
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');I hope it could do something for you
    thanks
    regards:
    usman noshahi

  • IDOC to MSsql,  error in mapping(Violation of PRIMARY KEY constraint)

    Hi All,
    I'm working with MATMAS IDOC  to MSSql. My SQL structure is of 8 tables(multiple statements) with primary key. In mapping i have used UPDATE_INSERT in action field for all the tables but still im getting "Violation of PRIMARY KEY constraint" for the last table structure. first 7 tables are single occurances but the 8th structure data is coming multple times from IDOC(E1MARMM).
    my 8th table structure is :
    STATEMENT8                                IDOC(MAPPED)
    TABLE8
    ACTION                                      UPDATE_INSERT
    TABLE                                           TABLENAME
    ACCESS     0 to Unbounded            MAPPED with E1MARMM
    Item_CD                                used oneasmany +splitbyvalue with MATNR
    Plant_ID                                  used oneasmany +splitbyvalue with WERKS  
    EAN_CAT                                 used oneasmany +splitbyvalue with NUMTP
    EAN                                             used oneasmany +splitbyvalue with EAN11
    Numerator_For_Conversion_To_BaseUOM
    Display_UOM
    Denominator_for_conversion_To_baseUOM
    KEY           0 to Unbounded                 MAPPED with E1MARMM
    Item_CD                                used oneasmany +splitbyvalue with MATNR
    Plant_ID                                  used oneasmany +splitbyvalue with WERKS  
    EAN_CAT                                 used oneasmany +splitbyvalue with NUMTP
    EAN                                             used oneasmany +splitbyvalue with EAN11
    Display_UOM
    in test tab its fine and fetching number of times according to MARMM segments  but in END to END testing its triggering an error stating that
    ""Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'MM_EAN' (structure 'STATEMENT8'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_MM_EAN'. Cannot insert duplicate key in object 'dbo.MM_EAN'.  ""
    Plz help me regarding this..

    Hi team,
    How resolve the below error 
    Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
    Thanks,
    Ram
    RAM
    There can be two reasons
    1. The insert script used is having multiple instances of the records with Key as 12610 returned from the source query. If this is the issue add a logic to include only the unique set of id values for records by avoiding duplicates. There are several approaches
    for this like using ROW_NUMBER with PARTITION BY, using a join with derived table etc
    2. The record with Key 12610 already exist in your destination table and your script is again trying to insert another instances of record with same key. This can be avoided by adding a NOT EXISTS condition with a subquery which will check and return only
    those records which doesnt already exist in the source
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • AMT enrollment error - Violation of UNIQUE KEY constraint 'EN_EnrollmentRecords_AK'.

    Hello,
    I've trouble enrolling AMT computer with SCCM 2012
    I've foud the following error in Amtproxymgr.log
    15/05/2014 14:54:50     
    Found instruction file: D:\Apps\Microsoft Configuration Manager\inboxes\amtproxymgr.box\{C6B0AAB5-BB02-4673-B44A-118917419389}.OTP
    15/05/2014 14:54:50     
    It's client provisioning request to be processed.
    15/05/2014 14:54:50     
    Stored provisioning request into database. SMSID: Machine_GUID
    15/05/2014 14:54:50     
    Target machine SMSID:Machine_GUID is a AMT capable machine.
    15/05/2014 14:54:50     
    Passed SanityCheckBeforeProvision(). FQDN is MYCOMPUTERNAME.domain.
    15/05/2014 14:54:50     
    BASE64 string OTP is : OTP_STRING
    15/05/2014 14:54:58      *** EN_EnrollmentAdminInsert @ProfileId = '16777217', @AssignedSiteCode = N'SITE_CODE', @DeviceName = N'MYCOMPUTERNAME', @ResourceID = '16816953', @OwnerIdentity = N'', @ClientType
    = '1', @OrganizationUnit = N'LDAP://OU=OU_NAME
    15/05/2014 14:54:58     
    *** [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of UNIQUE KEY constraint 'EN_EnrollmentRecords_AK'. Cannot insert duplicate key in object 'dbo.EN_EnrollmentRecords'. The duplicate key value is (MYCOMPUTERNAME). : EN_EnrollmentAdminInsert
    15/05/2014 14:54:58     
    Fail to insert Enrollment Record!
    15/05/2014 14:54:58     
    Error: Failed to create enrollment record.
    If I do a query on V_R_SYSTEM the resource ID for MYCOMPUTERNAME is 16816953.
    If I do a query on EN_EnrollmentRecords the Ressource Id associated  to
    MYCOMPUTERNAME is 16777351
    So there is already a record for MYCOMPUTERNAME in
    EN_EnrollmentRecords.
    I think the reason is that the computer resource has been removed from SCCM and then readded. The computer has now a new Ressource ID. But the deletion of the previous computer ID did not removed the record from
    EN_EnrollmentRecords.
    How can I solve this ?

    Open Sql Server Management Studio, and do the query below.
    select * from dbo.en_EnrollmentRecords where ResourceID ='16777351'
    delete from dbo.EN_EnrollmentRecords where ResourceID = '16777351'
    Delete the Device from console and AD and try provisioning again.
    Note: Please backup your Database before doing this modification. Modifying database will be at your own risk.
    Juke Chou
    TechNet Community Support

  • Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?

    Hi team,
    How resolve the below error 
    Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
    Thanks,
    Ram
    RAM

    Hi team,
    How resolve the below error 
    Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
    Thanks,
    Ram
    RAM
    There can be two reasons
    1. The insert script used is having multiple instances of the records with Key as 12610 returned from the source query. If this is the issue add a logic to include only the unique set of id values for records by avoiding duplicates. There are several approaches
    for this like using ROW_NUMBER with PARTITION BY, using a join with derived table etc
    2. The record with Key 12610 already exist in your destination table and your script is again trying to insert another instances of record with same key. This can be avoided by adding a NOT EXISTS condition with a subquery which will check and return only
    those records which doesnt already exist in the source
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Difference between Primary Key and Unique Key with NOT NULL constraint

    As both can be referred to another table.
    Apart from the difference that Primary Key can be only 1 and Unique keys can be multiple,
    is there any difference?
    Like in terms of type of Index?

    PARAG_C wrote:
    As both can be referred to another table.
    Apart from the difference that Primary Key can be only 1 and Unique keys can be multiple,
    is there any difference?
    Like in terms of type of Index?Technically there is almost no difference. Logically the two are often used for slightly different concepts.
    The PK (and with it the index) is often an ID column filled by a seqeunce. This key can then be refenced by foreign key constraints on other tables. it is very useful to have this as a meaningless technical construct. Because then the chance that such a ID needs to be changed is extremly slim.
    The UK (and with it the index) is often one or several columns that represent the logical key for the entity. Foreign key constriants should not point to this. THe chance that this attribute will be changed at some point in time is way higher then for a meaningless number (ID).

  • 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

  • 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,

  • Error when installing SM7 "The step runMigrationMonitor with step key "

    Hi all
    Please help for the following error when installing
    ERROR 2009-06-13 00:27:13.515
    FCO-00011  The step runMigrationMonitor with step key |NW_Onehost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|2|0|NW_CreateDBandLoad|ind|ind|ind|ind|10|0|NW_ABAP_Import_Dialog|ind|ind|ind|ind|5|0|NW_ABAP_Import|ind|ind|ind|ind|0|0|runMigrationMonitor was executed with status ERROR .
    Regards
    Kevin

    Hi Uday
    import.monitor.java.log
    Loading of 'SASACONT1' import package: OK
    Import Monitor jobs: running 2, waiting 23, completed 4, failed 0, total 29.
    Import Monitor jobs: running 3, waiting 22, completed 4, failed 0, total 29.
    Loading of 'SAPSSEXC' import package: ERROR
    Import Monitor jobs: running 2, waiting 22, completed 4, failed 1, total 29.
    Loading of 'REPOSRC' import package: ERROR
    Import Monitor jobs: running 1, waiting 22, completed 4, failed 2, total 29.
    Loading of 'SAPAPPL0' import package: ERROR
    Import Monitor jobs: running 0, waiting 22, completed 4, failed 3, total 29.
    Import Monitor jobs: running 1, waiting 21, completed 4, failed 3, total 29.
    Import Monitor jobs: running 2, waiting 20, completed 4, failed 3, total 29.
    Import Monitor jobs: running 3, waiting 19, completed 4, failed 3, total 29.
    Loading of 'DOKCLU' import package: ERROR
    Import Monitor jobs: running 2, waiting 19, completed 4, failed 4, total 29.
    Loading of 'SAPAPPL1' import package: ERROR
    Import Monitor jobs: running 1, waiting 19, completed 4, failed 5, total 29.
    Loading of 'SAPAPPL2' import package: ERROR
    Import Monitor jobs: running 0, waiting 19, completed 4, failed 6, total 29.
    Import Monitor jobs: running 1, waiting 18, completed 4, failed 6, total 29.
    Import Monitor jobs: running 2, waiting 17, completed 4, failed 6, total 29.
    Import Monitor jobs: running 3, waiting 16, completed 4, failed 6, total 29.
    Loading of 'DD03L' import package: ERROR
    Import Monitor jobs: running 2, waiting 16, completed 4, failed 7, total 29.
    Loading of 'SAPSSRC' import package: ERROR
    Import Monitor jobs: running 1, waiting 16, completed 4, failed 8, total 29.
    Loading of 'STERM_TEXT' import package: ERROR
    Import Monitor jobs: running 0, waiting 16, completed 4, failed 9, total 29.
    Import Monitor jobs: running 1, waiting 15, completed 4, failed 9, total 29.
    Import Monitor jobs: running 2, waiting 14, completed 4, failed 9, total 29.
    Import Monitor jobs: running 3, waiting 13, completed 4, failed 9, total 29.
    Loading of 'SEOSUBCODF' import package: ERROR
    Import Monitor jobs: running 2, waiting 13, completed 4, failed 10, total 29.
    Loading of 'E071K' import package: ERROR
    Import Monitor jobs: running 1, waiting 13, completed 4, failed 11, total 29.
    Loading of 'SAPSDIC' import package: ERROR
    Import Monitor jobs: running 0, waiting 13, completed 4, failed 12, total 29.
    Import Monitor jobs: running 1, waiting 12, completed 4, failed 12, total 29.
    Import Monitor jobs: running 2, waiting 11, completed 4, failed 12, total 29.
    Import Monitor jobs: running 3, waiting 10, completed 4, failed 12, total 29.
    Loading of 'ATAB' import package: ERROR
    Import Monitor jobs: running 2, waiting 10, completed 4, failed 13, total 29.
    Loading of 'SAPSPROT' import package: ERROR
    Import Monitor jobs: running 1, waiting 10, completed 4, failed 14, total 29.
    Loading of 'SAPSDOCU' import package: ERROR
    Import Monitor jobs: running 0, waiting 10, completed 4, failed 15, total 29.
    Import Monitor jobs: running 1, waiting 9, completed 4, failed 15, total 29.
    Import Monitor jobs: running 2, waiting 8, completed 4, failed 15, total 29.
    Import Monitor jobs: running 3, waiting 7, completed 4, failed 15, total 29.
    Loading of 'SAPPOOL' import package: ERROR
    Import Monitor jobs: running 2, waiting 7, completed 4, failed 16, total 29.
    Loading of 'SAPSLOAD' import package: ERROR
    Import Monitor jobs: running 1, waiting 7, completed 4, failed 17, total 29.
    Loading of 'SAPSLEXC' import package: ERROR
    Import Monitor jobs: running 0, waiting 7, completed 4, failed 18, total 29.
    Import Monitor jobs: running 1, waiting 6, completed 4, failed 18, total 29.
    Import Monitor jobs: running 2, waiting 5, completed 4, failed 18, total 29.
    Import Monitor jobs: running 3, waiting 4, completed 4, failed 18, total 29.
    Loading of 'SAPDDIM' import package: ERROR
    Import Monitor jobs: running 2, waiting 4, completed 4, failed 19, total 29.
    Loading of 'SAPDFACT' import package: ERROR
    Import Monitor jobs: running 1, waiting 4, completed 4, failed 20, total 29.
    Loading of 'SAPCLUST' import package: ERROR
    Import Monitor jobs: running 0, waiting 4, completed 4, failed 21, total 29.
    Import Monitor jobs: running 1, waiting 3, completed 4, failed 21, total 29.
    Import Monitor jobs: running 2, waiting 2, completed 4, failed 21, total 29.
    Import Monitor jobs: running 3, waiting 1, completed 4, failed 21, total 29.
    Loading of 'SAPDODS' import package: ERROR
    Import Monitor jobs: running 2, waiting 1, completed 4, failed 22, total 29.
    Loading of 'SAP0000' import package: ERROR
    Import Monitor jobs: running 1, waiting 1, completed 4, fail
    ed 23, total 29.
    Loading of 'SAPUSER' import package: ERROR
    Import Monitor jobs: running 0, waiting 1, completed 4, failed 24, total 29.
    Edited by: Kevin Wong on Jun 18, 2009 11:23 AM
    Edited by: Kevin Wong on Jun 18, 2009 11:24 AM

Maybe you are looking for

  • Change number of decimal in general settings after working .

    Hi, My customer was upgarded to sap2007 and changed the number of decimal in the "Amount" field to 4 ( it used to be 2) now after working a while he needs to change it back. Do you know what are the consequences of updating this field using an update

  • Is there a GBIC to sfc patch cable?

    I believe the currently installed fiber is GBIC, but the switch converter is mini-GBIC.  Is there a way to get these to work together?  Thanks.

  • Explain Plan for a simple join seems wrong

    I have been investigating some performance issues and I have discovered that a seemingly simple join generates a counter-intuitive execution plan. I have two tables, one of which represents users and the other of which represents learning activity tr

  • Surprised concerning size when measures added in cube

    Hello I am surprised to see that the size of the cube increases only by 14% when 3 measures are added in the cube with only one measure earlier. Initially, I maintained a cube with only one measure paidamt with datatype number(19,4). The tablespace s

  • Integration Services - MS Access

    Part of our information is in Microsoft Access. Also we have information in Essbase. Is posible to use/apply Essbase Integration Services for the information contained in tables in MS Access?Thanks,