Primary key allows duplicate entry in data dictionary

Hi Friends,
                 I have created table to save contact details. here i have assigned USERID and CELL_NO as primary key but when i am trying to create new entry it allows duplicate value. How can i prevent this ?
Please review my attached image for more details.
Thank you Friends.

Hi Karthi,
              I think table logic is correct. it mean if you entered both primary key same only it wont allow but here you mentioned same cell no but different ID so it will accepts.
E.g
     cell no 1234
     user id  xxx
     cell no 1234
    user  id xxx
above logic wont allows
but you mentioned
cell no 1234
user id xxx
cell no 1234
user id xyz
if you need to remove duplicates mean you should maintain primary key as cell no only not both..
revert back if you didnt get clear.
Regards,
   Thangam.P

Similar Messages

  • In which case composite primary key allows NULL values in it

    Hi to all
    In what case composite primary key allows nulls in it.
    Let us suppose, I created a composite primary key with 2 attributes.
    CREATE TABLE sample
    BNK_Id NUMBER(6),
    BNK_Name VARCHAR2(20),
    CONSTRAINT BNK_Id_Name_PK PRIMARY KEY(BNK_Id,BNK_Name)
    When it allows null values in it.
    thanks in advance

    Are you sure that your instructor was not talking about unique keys? As Solomon said, a primary key always implies not null on all of the columns of the PK. However a unique key does not automatically imply not null, and can have nulls in a column as long as the values in the populated columns are unique.
    SQL> create table test (
      2     id number,
      3     pid number,
      4     descr varchar2(10));
    Table created.
    SQL> alter table test add constraint test_unq
      2     unique (id, pid);
    Table altered.
    SQL> insert into test values (1, null, 'desc1');
    1 row created.
    SQL> insert into test values (2, null, 'desc2');
    1 row created.
    SQL> insert into test values (2, null, 'fail1');
    insert into test values (2, null, 'fail1')
    ERROR at line 1:
    ORA-00001: unique constraint (OPS$ORACLE.TEST_UNQ) violatedJohn

  • Updating Primary key while creating entries

    Hi All,
    I have a requirement to update a primary key while the entry is being created in the database table.
    The program uses the INSERT statement to create entries but the primary key is unknown at that time. I want to create this primary key value and update that record before being saved in the database.
    Is there a place where i can write this code which gets called while INSERT/UPDATE statements.
    Request you urgent help.
    Thanks in advance

    Hello Archana,
    As per my understanding providing BADI implementation is one of the better options you have.
    Firstly you have to find out the standard BADI Definition provided by SAP for your functionality. You can search the same in the transaction <b>SE18</b>.
    Your BADI definition will have predefined interface methods
    (like BEFORE_SAVE, AFTER_SAVE, BEFORE_UPDATE, AFTER_UPDATE ... )
    with necessary parameters(parameter types: IMPORTING/EXPORTING/CHANGING/RETURNING). Mind you, you can't add your own methods/parameters to these standard BADI definitions.
    Now you can create your own BADI implementation(ie., you can write you code in the one of the predefined methods you have) for the standard BADI definition. For that in your BADI Definition screen go to <i>Implementation</i> in Menu bar and click on <i>Create</i>.
    I hope you will definitely have <b>Primary Key</b> as importing parameter so you can write your code logic by using this primary key in one of the methods you have based on your requirement
    <b>@</b> Please take Backend expert help in your team for finding out BADI Definition Name & for also BADI Implementation Code if you are not sure about BADI concept.
    I hope this answers your question, If YES,  !!! REWARD POINTS !!!
    Regards, Srikanth

  • How can we export the Primary key values (along with other data) from an Advantage database?

    One of our customers is moving from our application (which uses Advantage Database Server) to another application (which uses other database technology). They have asked us to help export their data, so that they can migrate it to another database system. So far, we have used the Advantage Data Architect (ARC32) "Export Table Structures as Code" functionality to generate SQL. We used the "Include existing data" option. The SQL contains the necessary code to recreate the tables and indexes. The customer's IT staff will alter the SQL statements as necessary for their new system.
    However, there is an issue with the Primary Keys in these table. The resulting INSERT statements use AutoInc as the type for the Primary Key in each Table. These INSERT statements contains "DEFAULT" for the value of each of these AutoInc fields. The customer would like to output an integer value for each of these Primary Key values in order to maintain referential integrity in their new system.
    So far, I have not found any feature of ARC32 that allows us to export the Primary Key values. We had been using an older version of ARC32, since our application does not use the latest version of ADS. I did download the latest version of ARC32 (11.10), but it does not appear to include any new functionality that would facilitate doing this sort of export.
    Can somebody tell me if there is such a feature in ARC32?
    Or, is there is another Advantage tool to facilitate what we are trying to accomplish?
    If there are no Advantage tools to provide such functionality, what else would you suggest?

    George,
      It sounds like the approach you are using is the correct one. This seems to be the cleanest solution to me especially since the customer is able to modify the generated SQL statements for their new system.
      In order to preserve the AutoInc values I would recommend altering the table and changing the field datatype from AutoInc to Integer. Then export the table as code which will export the actual values. After the tables have been created on the new system they can change the field datatype back to an AutoInc type if necessary.
    Regards,
    Chris Franz

  • How to add primary key for table with existing data?

    The table is occupied data already. There was no primary key before, so for every column, there are some duplicate values.
    I want to add a new column, which should be of the datatype integer, and can automatically increment, starting from 001. I tried this in Oracle SQL Developer, but it says "ORA-01758: table must be empty to add mandatory (NOT NULL) column". How can I do it? Thanks!

    Hello, don't call the column ID, that could be an ID relating to anything. Perhaps be a little more specific like emp_id .
    Then to update it:
    UPDATE Employee emp
      SET emp_id = (
      SELECT row_num
        FROM (
      SELECT ROWID,
                 ROW_NUMBER() OVER (ORDER BY ROWID) row_num
        FROM Employee emp2) emp2
      WHERE emp.ROWID = emp2.ROWID);That will assign a new EMP_ID for each, beginning at 1.
    Then:
    ALTER TABLE Employee MODIFY emp_id NOT NULL;
    ALTER TABLE Employee ADD CONSTRAINT EMP_PK PRIMARY KEY (EMP_ID);Then create a sequence for future population of the Employee table:
    CREATE SEQUENCE emp_seq START WITH <maximum value of emp_id + 1>;

  • Events for changed entry in data dictionary

    Hi ,
    I  have a requirement as mentioned below:
    my table has four fields : 1. vkorg 2. validity_period 3. modification_date and 4. modification_time.
    I have to capture the modification date and modification time if a user changes an entry (or entries) in the table and update the date and time fields in the table.  I have done it by creating an event "creating a new entry"which is triggered when a new entry is added to the table. But if an existing entry is modifies then the entry is not triggered. when I use  " before saving the data " event then only the last record of the table moves to the "Routine"  of the event. So I am not able to capture the date and time when an entry (or entries ) is modified.  Can anyone suggest me what I should do?
    Regards
    Amit kumar
    Edited by: amitku1201 on Jan 15, 2010 3:05 PM

    This question has been asked many times before. Please see:
    *&      Form  FILL_SY_FIELDS                                    FISKROB
    *       Add the creation date and userid if the line is being created.
    *       Add the change date and userid if the line is being changed.
    form fill_sy_fields.
      data: f_index like sy-tabix. "Index to note the lines found
      data begin of total_s.
              include structure zzv_my_tab.
      data action.
      data mark.
      data end of total_s.
      data extract_s like total_s.
      loop at total.
        if <action> = 'U'.
          move total to total_s.
          read table extract with key total.
          if sy-subrc eq 0.
            f_index = sy-tabix.
            extract_s = extract.
          else.
            clear f_index.
          endif.
    *       (make desired changes to the line TOTAL)
          total_s-zzfchdate = sy-datum.
          total_s-zzfchusr  = sy-uname.
          move total_s to total.
          modify total.
          check f_index gt 0.
          extract = total.
          modify extract index f_index.
        elseif <action> = 'N'.
          move total to total_s.
          read table extract with key total.
          if sy-subrc eq 0.
            f_index = sy-tabix.
            extract_s = extract.
          else.
            clear f_index.
          endif.
    *       (make desired changes to the line TOTAL)
          total_s-zzfcredate = sy-datum.
          total_s-zzfcreusr  = sy-uname.
          move total_s to total.
          modify total.
          check f_index gt 0.
          extract = total.
          modify extract index f_index.
        elseif total is initial.
          move total to total_s.
          read table extract with key total.
          if sy-subrc eq 0.
            f_index = sy-tabix.
            extract_s = extract.
          else.
            clear f_index.
          endif.
    *       (make desired changes to the line TOTAL)
          delete total.
          check f_index gt 0.
          delete extract index f_index.
        endif.
      endloop.
      sy-subrc = 0.
    endform.                    " FILL_SY_FIELDS
    Rob
    The link I posted earlier may not work now. The above code does.
    Edited by: Rob Burbank on Jan 15, 2010 12:20 PM

  • Syncing iCal to iPod duplicate entries different dates

    I'm trying to sync iCal events with my iPod nano (2nd Gen) using iTunes 7.3. However, each calendar event appears twice--once on the actual date, and once to the follow date. The duplicate events do not appear in iCal, only on the iPod. How can I stop these duplicate events from being created on the iPod?
    PowerBook G4   Mac OS X (10.4.9)   iPod nano 2nd Gen, iPhone 8G

    Reset iPod.

  • How to make a column a primary key so duplicate records cannot be added

    I have a text column called JPPNum, and I want to make it so a user cannot add the same JPP Number if the record with that JPP number is already in there. So no duplicate on JPP NUm, how would I do that?
    Thank you.

    hi,
    refer to the below article you just have to specify the "yes" in "enforce unique values" 
    setting of column.
    http://www.c-sharpcorner.com/uploadfile/anavijai/unique-column-constraints-in-sharepoint-2010/
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

  • Java Dictionary Primary Key

    Hello,
      I'm creating some database tables in the Java Dictionary on Web AS 6.40.  What is the best way to create unique identifiers for the primary key of these tables?  In ABAP Dictionary you would use a number range.  Is there an equivalent or other technique for the Java Dictionary?
    Thanks,
    Dustin

    Hi Dustin,
    the best way is if the logic of your data represent a primary key. If your central data object for example is a project, it will have a project number, and this is unique, so predestinated to be the primary key. If a customer has an order for this project (maybe the project is handled via two or three single orders), you will have an "order" table. For single customers having unique order IDs, the combination of the customers order id and the project id (foreign key) are predestinated to be the primary key.
    If such a logic does not work, it's up to you to implement something (automatic PK generation does not work with the Java Dictionary). A number range seems to be ABAP... I would prefer a PKGenerator, for example generating them out of a combination of timestamp and random number or chars (sure, managing that the generated keys are unique).
    Hope it helps
    Detlev

  • Prevent duplicate entry

    I would like to make sure there are no duplicate data entries in my Oracle 9i table (called MainTable) which has an Id field that is the primary key, ValData with a varchar data type, Fid and Fid2 are number data types.
    Id   ValData   Fid   Fid2
    1    abc       34    2
    2    efg       23    34
    3    zeo       25    43Sometimes someone can enter a duplicate ValData, Fid and Fid2 and it will end up like this:
    Id   ValData   Fid   Fid2
    1    abc       34    2
    2    efg       23    34
    3    zeo       25    43
    4    zeo       25    43What constraints or restrictions can I place on the MainTable where it will never allow a duplicate entry into the table?
    I would like to do this somehow in the database. If someone tries to enter a duplicate I should get a error message or something to indicate an attempt to enter duplicate data.
    Please advise if this is possible?

    We told you above - next level of support is onsite but not sure your zipcode is similar to mine.
    First you have to clarify if the three fields must be uniq as a combination or if valdata alone cannot be duplicated. In other words:
    id valdata fid fid2
    1 abc 34 2
    2 abc 23 34
    is this legal?
    Depending on the answer you apply the appropriate solution. If answer is yes, you apply this:
    alter table <table name> add constraint uniq_combination unique (valdata, fid, fid2);
    if answer is that it is illegal because you want to prevent valdata alone to assume duplicate values, then:
    alter table <table name> add constraint uniq_valdata unique (valdata);
    See Guido's comment above concerning the handling of the DB generated error.
    enrico

  • Need advice on preventing duplicate entries in People table

    Hi,
    In my database, I have a "People" table where I store basic information about people e.g. PersonId, FirstName, LastName, Gender, etc.
    There will be lots of entries made into this table and I want to prevent duplicate entries as much as humanly possible. I'd appreciate some pointers on what I should do to minimize duplicates.
    My primary concerns are:
    Duplicate entries for the same person using the person's full name vs. given name e.g. Mike Smith and Michael Smith
    Making sure that two separate individuals with identical names do get entered into the table and get their unique PersonId's.
    Not even sure how I can even possibly know if two individuals with identical names are two different people without having additional information but I wanted to ask the question anyway.
    Thanks, Sam

    Thank you all very much for your responses.
    There are three separate issues/points here.
    It is clear that it is impossible to prevent duplicates using only a person's first, middle and last names. Once I rely on an additional piece of information, then things get "easier" though nothing is bullet proof. I felt that this was self evident but
    wanted to ask the question anyway.
    Second issue is "potential" duplicates where there are some variations in the name e.g. Mike vs Michael. I'd like a bit more advice on this. I assume I need to create a table to define variations of a name to catch potential duplicates.
    The third point is what Celko brought up -- rather nicely too :-) I understand both his and Erland's points on this as typical relational DB designs usually create people/user tables based upon their context e.g. Employees, Customers, etc.
    I fundamentally disagree with this approach -- though it is currently the norm in most commercial DB designs. The reason for that is that it actually creates duplicates and my point is to prevent them. I'm going for more of an object based approach in the DB
    design where a person is a person regardless of the different roles he/she may play and I see no reason in repeating some of the information about the person e.g. repeating first, last name, gender, etc in both customer and employee tables.
    I strongly believe that all the information that are directly related to a person should be kept in the People table and referenced in different business contexts as necessary.
    For example, I assign every person a PersonId in the People table. I then use the PersonId as part of the primary key in the Customers or Employees table as well. Obviously, PersonId is also a foreign key in Customers and Employees tables. This prevents the
    need for a separate CustomerId and allows me to centralize all the personal data in the People table.
    In my opinion this has three advantages:
    Prevent duplication of data
    Allow global edits e.g. if the last name of a female employee changes, it is automatically updated for her within the context of "Customer" role she may play in the application.
    Last but not least, data enrichment where a person may enter additional data about himself/herself in different contexts. For example, in the employee context, we may have the person's spouse information through "Emergency Contacts" which may come handy
    within the context of customer for this person.
    Having everyone in the People table gives me these three advantages.
    Thanks, Sam

  • What are these duplicate entries in table T445M ?

    Hi,
    In table T445M, there are records for each line in my macro - and they have AR columns blank, and RL columns with zero value.  However, those same records are also duplicated - but now with R in AR columns, and 52 in RL columns (i.e. table T445M has double the number of records than the lines in my macro).
    So any idea how these duplicate records get created, and what is the meaning of the values in AR & RL columns ?
    Also, I see a column "Functional Module Name" - so can someone explain how to use FM in macro ?
    Thanks,
    - Chetan

    Hi,
    please help me in that counter loop code..how to do this!!
    and how to code for duplicate entries.
    DATA:  ITAB21 TYPE hashed TABLE OF zmailhist WITH UNIQUE key mandt vbeln kunnr,
           WA LIKE LINE OF ITAB21.
    WA-VBELN = P_VBELN.
          INSERT WA INTO TABLE ITAB21.
          WA-KUNNR = P_KUNNR.
          INSERT WA INTO TABLE ITAB21.
          TRANSLATE V_ID TO LOWER CASE.
          CONCATENATE V_ID '@cadence.com'  INTO CHAR1.
          WA-UNAME = CHAR1.
          INSERT WA INTO TABLE ITAB21.
          WA-VSURA = SY-UZEIT.
          INSERT WA INTO TABLE ITAB21.
          WA-ERDAT = SY-DATUM.
          INSERT WA INTO TABLE ITAB21.
              IF SY-SUBRC = 0.
                 V_VSTAT = '0'.
              ELSE.
                 V_VSTAT = '1'.
              ENDIF.
          WA-VSTAT = V_VSTAT.
          INSERT WA INTO TABLE ITAB21.
          WA-NAME1 = I_TAB1-EMAIL.
          INSERT WA INTO TABLE ITAB21.
    INSERT zmailhist FROM TABLE ITAB21 ACCEPTING DUPLICATE KEYS.
    its not picking the duplicate entries..pls help

  • Duplicate entries in table & email count

    hi,,
    In my selection screen i have 3 fields-
    billing doc--vbeln
    customer no--kunnr
    email id -
    when i give inputs in this selection screen fields and execute it mail is sent and
    the inputs given for the fields are stored in a ZTABLE.
    my requirement is if user is entering 90073336,66789 and daniel
    once it gets stored in the ztable. if once again i am giving the
    same input, it doesnot get stored in my ztable.
    can i get duplicate entries in my ztable. if yes how?
    and if my receiver mail id is daniel
    no of times email count should be one.if again daniel then two.
    if harry.the one.
    thnx..

    Hi,
    please help me in that counter loop code..how to do this!!
    and how to code for duplicate entries.
    DATA:  ITAB21 TYPE hashed TABLE OF zmailhist WITH UNIQUE key mandt vbeln kunnr,
           WA LIKE LINE OF ITAB21.
    WA-VBELN = P_VBELN.
          INSERT WA INTO TABLE ITAB21.
          WA-KUNNR = P_KUNNR.
          INSERT WA INTO TABLE ITAB21.
          TRANSLATE V_ID TO LOWER CASE.
          CONCATENATE V_ID '@cadence.com'  INTO CHAR1.
          WA-UNAME = CHAR1.
          INSERT WA INTO TABLE ITAB21.
          WA-VSURA = SY-UZEIT.
          INSERT WA INTO TABLE ITAB21.
          WA-ERDAT = SY-DATUM.
          INSERT WA INTO TABLE ITAB21.
              IF SY-SUBRC = 0.
                 V_VSTAT = '0'.
              ELSE.
                 V_VSTAT = '1'.
              ENDIF.
          WA-VSTAT = V_VSTAT.
          INSERT WA INTO TABLE ITAB21.
          WA-NAME1 = I_TAB1-EMAIL.
          INSERT WA INTO TABLE ITAB21.
    INSERT zmailhist FROM TABLE ITAB21 ACCEPTING DUPLICATE KEYS.
    its not picking the duplicate entries..pls help

  • Updating a table with no Primary key

    What I am trying to find out is if you can uniquely update a single record in a table that has no primary key. I see no way to reference the record I want, other than specifying all the field values in a where clause. This is a problem though, because if I have another record with the same field values, that will get updated too. (I know its a bad database design, but some people do it and I need to work around it!!!), there are some situations where you would have identical records as far as a where clause is concerned, for example, you cant use a blob in a where clause so that might be where your records differ...
    In SQLServer 2000, Enterprise manager throws an error if you have a table with no primary key and duplicate records that you try to update through the GUI. EM uses stored procedures to execute updates, and it rolls back ones which result in more than one update result.
    Im not too familiar with Cursors in SQL, only that they are quite slow and not implemented on all DB products. But I think that they might be able to solve the problem (but I dont logically see how).
    Can anybody explain this to me?

    another record with the same field valuesIf you have two records and all the field values are the same then the records are logically the same anyways, so it shouldn't matter if you update both (one would question why there are two records in the first place.) In other words there is no way, either computationally or manually to tell them apart.
    I suspect that that is rather rare. Instead what is more likely is that you are only using some of the fields. So just keep adding fields until it is unique.

  • Primary key is null in CMP ejbLoad()

    Using WebLogic 7.0 with Oracle 9i Lite.
    We're logging the values of the CMP fields in ejbLoad(). All of the
    CMP values look fine, except for the primary key value; it's always
    null. This means that Foo.getKey() (the CMP field that returns the
    primary key value) always returns null.
    Foo.getPrimaryKey() works as expected.
    This appears to be causing problems with CMR fields. The Collection
    we get from a "many" CMR field is populated with the correct number of
    elements, but if we try to remove one of them we're getting a "primary
    key cannot be null" exception from the container.
    Any insights?
    Richard A. Steele
    Paychex

    Here's some more information:
    We're able to successfully create entity beans; for example, we have beans OrganizationEJB
    and BusinessSiteEJB. There's a one-to-many relationship from OrganizationEJB to
    BusinessSiteEJB.
    Because of database integrity constraints, when we create a BusinessSite, we have
    to provide the Organization as a parameter to create(). This works fine--after calling
    create(), I see the new BusinessSite in the database.
    We can also do a findByPrimaryKey() on BusinessSite and retrieve the business site.
    However, if I do a getBusinessSites() on Organization, I get back a Collection, but:
    1. Sometimes it has just a single entry, even if we know there are multiple business
    sites for this organization. Sometimes, it has the right number of entries, but
    every one of them is identical.
    2. The primary key of the entries in the Collection are all null. In other words,
    if I do a getPrimaryKey() on the BusinessSite local interfaces in the collection,
    I get back null.
    3. If I try to delete any of the Business Sites in the collection, the container
    throws an exception that the primary key can't be null.
    Richard A. Steele
    Paychex

Maybe you are looking for

  • EWA,SL reporting into BI

    Hi.. Can somebody help in configuring the BI for solution manager. I want to push the data from solution manager like EWA,SL,System monitoring reports in to BI. and later i need to extract from BI as and when required.. Help me with the documentation

  • Numeric value

    im using ECC 5.0 , here during BOM creation my ratio of FERT and ROH is 1:1.82 but when i put this value 1.82 there system gives me below message Enter a numeric value Message no. 00052 Plz help mei want to put value of 1.82 but system not allowing m

  • How do I get Farmville2 to load properly?

    The pop ups for quest and the like are over sized and I can not hit a send button or close the pop up to continue playing the game. It looks really large and it has been going on for the last 2 days.

  • Calling variables from a loop

    Hi I have 6 variables declaerd: b_banner0 iloug.iloug_activities.banner0%type; b_banner1 iloug.iloug_activities.banner1%type; b_banner2 iloug.iloug_activities.banner2%type; b_banner3 iloug.iloug_activities.banner3%type; b_banner4 iloug.iloug_activiti

  • Hauppauge High Definition Video Capture

    Does anyone have experience of the "Hauppauge HD PVR USB Hi-def H.264 Video Capture Device,high Definition USB 2.0 Video Capture With Hardware H.264 Video Encoders"? If so what do you think of it? Leaving aside PVR (it isn't in my opinion as it needs