Duplicate entries for same primary key

Hi,
I am facing problem to insert 2 or more than 2 entries for same PRIMARY KEY in the database table.
As I know that we can’t do that. But Client has given me the XL sheet which contains 2 entries for same primary key. How can it be done? Please let me know how can I insert 2 data for same primary key in database table.
Waiting for your answers.
Thanks in advance.
Regards,
Prasanna

Hi,
  You can achieve this .... All you have to do is to add a new field (a Sequence Number ) to the table. This number will be incremented for each duplicate primary keys. For example....
Consider the excel file has duplicate entries 3 primary keys. Now you add a new field named Sequence Number in your DB Table.....
When you load the data into Database...then the records will look like this...
Key1     Key2    Key3    Seq
A          B          C           1
A          B          C           2
A          B          D           1
A          B          D           2
A          C          D           1
A          C          E           1
  and so on...
I hope this solves your purpose.....
Whenever there are duplicate entries, such as the one mentioned in your scenario, then a new field can be added in Database. This field acts like a count or sequence number.... Thus you can maintain unique records.
Regards,
Vara
Regards,
Vara

Similar Messages

  • Duplicate record with same primary key in Fact table

    Hi all,
       Can the fact table have duplicate record with same primary key . When i checked a cube i could see records with same primary key combination but the key figure values are different. My cube has 6 dimentions (Including Time,Unit and DP) and 2 key figures. So 6 fields combined to form the composite primary key of the fact table. When i checked the records in se16 i could see duplicate records with same primary key. Ther are no parallel loading happening for the cube.
    BW system version is 3.1
    Data base is : Oracle 10.2
    I am not sure how is this possible.
    Regards,
    PM

    Hi Krish,
       I checked the datapacket dimention also. Both the record have same dimention id (141). Except the Keyfigure value there is no other change in the Fact table record.  I know this is against the basic DBMS primary key rule. But i have records like this in the cube.
    Can this situation arise when same records is there in different data packet of same request.
    Thx,
    PM
    null

  • How do I obtain the next number for a Primary Key using an ADF View Object?

    I have two separate View Objects (A & B) for the same Entity Object. View Object A does a SELECT on all of the fields in the table. This View Object is where I execute my adds and updates. View Object B is only used to retrieve the next number for the primary key. This is done so that when I add a row to the database, I always get the max number of the primary key and add one to it. I accomplished this by setting the SQL mode to Expert and using the SQL: "SELECT MAX(NBR) AS MAX_NUMBER FROM TABLE_1". This may be overkill having a seperate View Object for this, but so far this is the only way I have found to obtain the next number. However, I have discovered that this way does not always work.
    The problem I'm running into is when I try to add multiple records to View Object A without committing the transaction between each add. Because View Object B is disconnected from View Object A, the MAX_NUMBER of View Object B comes back with the same number for each add I do on View Object A. So I know I must retrieve the MAX_NUMBER from View Object A.
    I've tried using the following code in my Table1ViewImpl class:
    this.setQuery("SELECT MAX(Table1.NBR) AS MAX_NUMBER FROM TABLE_1 Table1");
    this.executeQuery();
    The view object now has what I want, but I have yet to figure a way to extract the MAX_NUMBER out of the View Object. I've also looked into using the method addDynamicAttribute() but I can't figure out any way to set the attribute with the MAX_NUMBER.
    I can't be the only one trying to retrieve the next number from a database table using ADF. Can anyone help me with this? FYI - I'm using JDev 10.1.3 EA.

    You missing the point.
    On a multi-user db knowing the next highest number doesn't guarantee the number will be available when it comes time to commit the record. You can prove this to yourself by opening two instances of your app and do whatever you do to add a new record to your VO. Both will assume the same number, and when you commit an error will be generated
    You must use sequences to avoid the possibility of duplicate keys. If you are trying to avoid gaps in your numbering then you need to convince yourself why this is necessary.

  • 2 tables with same primary key

    Hi,
    2 tables with same primary key is possible,but when is wise to go for such ?
    is that a bad desisn ?
    eg:
    Personal_details_employee
    Official_details_employee
    these 2 tables have same Primary key emp_id.
    plz. reply me at [email protected] also
    thanx
    vikram

    hi Vikram,
    In this case u can have then in one table itself and why do want to have two tables.
    - Suresh.A

  • [Incoming Payments for WTax] Primary Key not exist in DB

    While performing the TDS upgrade, I am getting an error message as "[Incoming Payments for WTax] Primary Key not exist in DB".
    I have checked that the sheet conforms to the instructions provided in the Upgrade guide but am not able to resolve this.
    Any ideas?
    Regards,
    Gyanesh

    Hi,
    It seems to be some field in the TDS upload Excel sheet which has primary key field not having the correct value.
    Double check the same where Primary Key if linked with some value in other sheet, enter the same.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Is this good approach for generating Primary Keys ?

    Hi,
    All our EJBs are state less Session Beans.
    We have created a state less Session(name SequenceEJB) for getting Primary Key.
    Thre is a method,
    int getSequenceNumber(String tableName,String fieldName) in SequenceEJB. And the following query is used in the above said method.
    SELECT MAX("+fieldName+") ID FROM "+tableName
    Each EJB will lookup SequenceEJB, and call the above said method for getting sequence number.
    Is this approach sclable ?
    Can we proceed by this approach ?
    Thanks in advance
    Srinivas

    As long as you are in EJB, synchronization won't help you because it is not permitted by the EJB spec.
    If you can go with JDBC 3.0 / Java 1.4, the statement interface supportes generated keys. See http://java.sun.com/j2se/1.4/docs/api/java/sql/Statement.html.
    If you cannot go with JDBC 3.0 / Java 1.4, you can implement the key-generation db-specific (e.g. using oracle sequences for oracle tables, and whatever exists for DB2, SQL Server etc.) That of course requires special support for all databases, but at least you can run your app with different databases.
    Or you can try to do it the following way, using a separate table for the keys.
    ResultSet rs = statement.executeQuery("select id from mySequences");
    oldId = rs.getInt(1);
    newId = oldId + 1
    int updatedRows = statement.executeQuery("update mySequences set id = newId where id = oldId");
    if(updatedRows == 1) {
      // succesful
    } else {
      // not sucessful, somebody else has already retrieve this id; do something like Thread.sleep() and retry
    }This way, the database does the actual synchronization between the processes (each process sees the same data in the tables), and you implement the retry logic.

  • How to pass values for compound primary keys for updating the record in db.

    i have a entity bean in my ejb with two primary keys to it...eg. roleid,rolename...
    when iam retriving the record i use only one primary key ...so again to modify and update he same record which i retrived is a pbm..
    i cannot set the values for the compoundpk,,,
    but i can do the update for the bean with single primary key..
    i need to know how to pass the values/parameters for the coumpound primary key in my update method...
    thanx in advance...
    Arjun.G

    I istantiated a object for the pk class and assign the values for the primary key fields...
    Arjun.G

  • Ipad still showing duplicate entries for songs.

    my Ipad still showing duplicate entries for songs. I have unchecked Show Itunes in the Cloud purchases, I have tried replacing all items when autofilling (before syncing) I have even logged out then back into itunes, to no avail. Can you please assist? Thank you

    hi guys, i was just googling the problem as i too have it, i am currently trying to sort it, i have deleted all my music off my phone using itunes and then put it all back on and also tried deleting it and outting 1 album on at a time, still not got rid of the duplicate tracks, i have now used the show duplicate items view and deleted those off my itunes library. i think i may have come across the problem!! i have just deleted all my music off my iphone using itunes again, and it shows nothing being on my iphone, however, if i go into music on my actual phone it is still showing 126 songs and none of them play. so i have now deleted them manually directly from the phone and am now putting all my music back onto my phone hoping i have cured the issue of ghost tracks.
    ill let you know when its done if we are cured!!
    BOOOOOMMMM!!!!! it worked!!! been so frustating, now its all good, hope this helps anyone with the same issues

  • How to specify  tablespace for a primary key inde in create table statement

    How to specify the tablespace for a primary key index in a create table statement?
    Does the following statement is right?
    CREATE TABLE 'GPS'||TO_CHAR(SYSDATE+1,'YYYYMMDD')
                ("ID" NUMBER(10,0) NOT NULL ENABLE,
                "IP_ADDRESS" VARCHAR2(32 BYTE),
                "EQUIPMENT_ID" VARCHAR2(32 BYTE),
                "PACKET_DT" DATE,
                "PACKET" VARCHAR2(255 BYTE),
                "PACKET_FORMAT" VARCHAR2(32 BYTE),
                "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
                 CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") TABLESPACE "INDEX_DATA"
                 TABLESPACE "SBM_DATA";   Thank you
    Edited by: qkc on 09-Nov-2009 13:42

    As orafad indicated, you'll have to use the USING INDEX clause from the documentation, i.e.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE TABLE GPS
      2              ("ID" NUMBER(10,0) NOT NULL ENABLE,
      3              "IP_ADDRESS" VARCHAR2(32 BYTE),
      4              "EQUIPMENT_ID" VARCHAR2(32 BYTE),
      5              "PACKET_DT" DATE,
      6              "PACKET" VARCHAR2(255 BYTE),
      7              "PACKET_FORMAT" VARCHAR2(32 BYTE),
      8              "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
      9               CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") USING INDEX TABLESP
    ACE "USERS"
    10               )
    11*              TABLESPACE "USERS"
    SQL> /
    Table created.Justin

  • How to change the source type for a primary key on a form?

    Hi,
    At the time of creating a form, I had set the source type for the primary key to an existing sequence.
    Now I want to change the source to a trigger.
    Can anyone suggest how to do it?
    Thanks in advance,
    Annie

    Annie:
    Define the trigger and then delete the page process named 'Get PK'
    Varad

  • Creating a script for a PRIMARY KEY USING INDEX SORT doesn't work

    Probably a bug.
    h1. Environment
    Application: Oracle SQL Developer Data Modeler
    Version: 3.0.0.655
    h1. Test Case:
    1. Create a new table TRANSACTIONS with some columns.
    2. Mark one of numeric columns as the primary key - PK_TRANSACTIONS.
    3. Go to Physical Models and create new Oracle Database 11g.
    4. Go to Physical Models -> Oracle Database 11g -> Tables -> TRANSACTIONS -> Primary Keys -> PK_TRANSACTIONS -> Properties:
    a) on General tab set Using Index to BY INDEX NAME
    b) on Using Index tab choose a tablespace
    c) on Using Index tab set Index Sort to SORTED.
    5. Export the schema to DDL script. For the primary key you will get something like this:
    ALTER TABLE TRANSACTION
    ADD CONSTRAINT PK_TRANSACTION PRIMARY KEY ( TRAN_ID ) DEFERRABLE
    USING INDEX
    PCTFREE 10
    MAXTRANS 255
    TABLESPACE TBSPC_INDX
    LOGGING
    STORAGE (
    INITIAL 65536
    NEXT 1048576
    PCTINCREASE 0
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    FREELISTS 1
    FREELIST GROUPS 1
    BUFFER_POOL DEFAULT
    ) SORTED
    h1. Reason of failure
    The script will fail because SORTED is not allowed here. It should be SORT.
    Additionally, the default behaviour for Data Modeler is to set Index Sort to NO but default setting for Oracle database 11g is SORT. Shouldn't Data Modeler use SORT as the default value?
    Edited by: user7420841 on 2011-05-07 03:15

    Hi,
    Thanks for reporting this problem. As you say, it should be SORT rather than SORTED. I have logged a bug on this.
    I also agree that, for consistency with the database default, it would be better to have SORT as the default in Data Modeler.
    David

  • ORA-13223: duplicate entry for string in SDO_GEOM_METADATA table and

    I got the above error while trying to insert a record into the table SDO_GEOM_METADATA. However, when querying this table I did find any duplicate table_name, column_name pair that match with the error.
    Here are the steps that I worked on:
    1. Add a geometry column into an existing table.
    ALTER TABLE GEO_MAP ADD (ORG_GEOM mdsys.sdo_geometry);
    2. Register the new column into mdsys
    insert into USER_SDO_GEOM_METADATA
    values ('GEO_MAP','ORG_GEOM',
    mdsys.sdo_dim_array(
    mdsys.sdo_dim_element('LONG',-180,180,0.00005),
    mdsys.sdo_dim_element('LAT',-90,90,0.00005)
    8307)
    I got the error ORA-13223: duplicate entry for string in SDO_GEOM_METADATA table even there was no such record in there.
    3. I inserted values in the column ORG_GEOM fine.
    4. However, when I tried to create the index for this column I got the error:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read
    Please help.
    Thanks.

    SQL> select * from mdsys.sdo_geom_metadata_table;
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    QW_USER1 GEO_REF
    LOC_GEOM
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('LONG', -180, 180, .00005), SDO_DIM_ELEMENT('LAT',
    -90, 90, .00005))
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    8307
    MDSYS SDO_CMT_CBK_RTREE_TAB
    GEOM
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .000000005), SDO_DIM_ELEMENT('Y',
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    -90, 90, .000000005))
    The situation is we have 2 tables (GEO_MAP, and GEO_REF) that have spatial columns. Everything worked fine until when one of the queries that searched through the table GEO_MAP ran so slow, we decided to rebuild the related spatial index by dropping and recreating it. However, after I dropped it I could not recreated. Keep getting the error:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read
    Any help is very much appreciated.

  • Overwriting a record with part of same primary key

    Hello Everyone,
    Could anyone please give a suggestion about how to overwrite the record with part of same primary key?
    I have  5 key fields.
    A1
    A2
    A3
    A4
    A5
    I have to overwrite the record if A5 changes with same A1 A2 A3 A4.
    I cannot take off A5 as part of primary key. If I use modify or insert, its creating a new record with the new A5. But I am still having the old record in the table (with old A5), which I don't want it to be there.
    Thank you,
    Rushi

    hi,
    That's right.
    u have to delete record from database table .....
    then u can add a new record...
    use delete <database_table> from table <internal_table>

  • Duplicate entry for WebUpdatePassword

    Hi,
    After siebel installtion , I found there is a duplicate entry for WebUpdatePassword in C:\sea78\SWEApp\BIN\eapps.cfg file. i.e. I can able to login to the siebel GUI after remove the duplicate line i.e "WebUpdatePassword = xxxxxxxxxxxxxxxxxxxxxxxxxxxx" . Please help me , If there is any wrong with installtion or it is a Siebel BUG. Please let me know , if I can provide any further information.
    [salesce_psj]
    ConnectString = siebel.TCPIP.None.None://host130:2321/sebl78eip/SalesCEObjMgr_psj
    EnableExtServiceOnly = TRUE
    WebPublicRootDir = c:\sea78\SWEApp\public\psj
    WebUpdatePassword = xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    WebUpdatePassword = xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [smc_psj]
    ConnectString = siebel.TCPIP.None.None://host130:2321/sebl78eip/SMCObjMgr_psj
    WebPublicRootDir = c:\sea78\SWEApp\public\psj
    WebUpdatePassword = xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Kind Regards
    Khirod Patra

    SQL> select * from mdsys.sdo_geom_metadata_table;
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    QW_USER1 GEO_REF
    LOC_GEOM
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('LONG', -180, 180, .00005), SDO_DIM_ELEMENT('LAT',
    -90, 90, .00005))
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    8307
    MDSYS SDO_CMT_CBK_RTREE_TAB
    GEOM
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .000000005), SDO_DIM_ELEMENT('Y',
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    -90, 90, .000000005))
    The situation is we have 2 tables (GEO_MAP, and GEO_REF) that have spatial columns. Everything worked fine until when one of the queries that searched through the table GEO_MAP ran so slow, we decided to rebuild the related spatial index by dropping and recreating it. However, after I dropped it I could not recreated. Keep getting the error:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read
    Any help is very much appreciated.

  • Exception: non-read-only mapping defined for the primary key field

    Hello.
    I'm new to Oracle and I created Java EE Web Project.
    And I created entities from tableA, tableB, tableC from my database.
    tableA has foreign key to tableB and has unidirectional Many-to-One relationship. tableC has two primary keys and one of these is foreign key to primary key in tableA. tableC also has unidirection Many-to-One relationship to tableA.
    Then I created session bean and data control from it, in design window, created read-only table from tableA.
    And I selected columns in tableA and also in tableB.
    I ran the application and saw the following exception in log window.
    Local Exception Stack:
    Exception [EclipseLink-46] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: There should be one non-read-only mapping defined for the primary key field [tableC.tableA_ID].
    Descriptor: RelationalDescriptor(mypack.tableC --> [DatabaseTable(tableC)])
    tableA_ID is a primary key in tableA.
    How can I solve this error?
    Please help me.
    Edited by: 900471 on 2011. 12. 3 오전 5:32
    Edited by: 900471 on 2011. 12. 3 오전 5:33
    Edited by: 900471 on 2011. 12. 3 오전 5:33
    Edited by: 900471 on 2011. 12. 3 오전 5:34

    There are not enough details to be sure since you have not provided the mappings. From just the error, it looks like you are using the tableC.tableA_ID field as the foreign key in the ManyToOne relationship to A, but have marked it as insertable=false, writeable=false, meaning that it cannot be updated or used for inserts.
    Either make it writable (set the settings to true), or add another basic mapping/attribute in the entity for TableC that maps to the field which you can use to set when you insert a new tableC entity. A simple example is available at
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/DerivedIdentifiers
    Best Regards,
    Chris

Maybe you are looking for

  • How to open a file in the same position on display when closing

    Not sure if this is the right place, so I apologize in advance: Whenever I open my text edit files, they always open in the same place in the display; how can I get these files (or any files for that matter) to open at the display position where they

  • What type of questions can i expect for master data?

    hi, am preparing for the interview. pls... let me know those questions for master data. thanks to all

  • User exit to check vendor tax type in tcode FB60

    Dear All, i need o create an user exit for FB60  check the vendor tax types . Plz advice. regards siva

  • Outer join confusion

    Hi, Can anybody please tell me the difference between these two queries. select * from T1, T2 where T1.C1 = T2.C1(+) and T1.C2 = 'Y'; select * from T1, T2 where T1.C1 = T2.C1(+) and T1.C2(+) = 'Y'; I am just confusing why add a outer join in case of

  • Error in activation in my iphone 4 (IOS 4.2.3)

    I am using Gevey iphone 4 (IOS 4.2.3), some hour ago i attached my phone with PC and open itune, then itune recommanded me to update my iphone software and i completed update my iphone, but after updation, my iphone is not activating my Gevey sim car