Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Primary key allows duplicate entry in data dictionary

Former Member
0 Kudos
2,303

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.

11 REPLIES 11
Read only

Former Member
0 Kudos
1,608

use semantic key at dtp level

Read only

0 Kudos
1,608

Could you please explain about that ?

Read only

Former Member
0 Kudos
1,608

Karthik,

There is nothing abnormal in the result..

The results are coming just the way you have defined it.

If you have defined both user id and cell no as primary key, then there will be a unique record for a combination of user id and cell no. If one of them changes, a new record would be created.

If you want only one record to be created for every cell no, make only cell no as the primary key, there wont be duplicates for cell no then.

Regards,

Susmitha

Read only

0 Kudos
1,608

Thanks for your reply . Now i am  clear about this. But is there any other way to check both fields to have unique value ?

Read only

0 Kudos
1,608

Yes its possible.

First as already mentioned create the table with cell_no as key.

This will prevent any duplicate values for cell_no.

Next, create an index for the table. Mark it as unique and include the field mandt and userid as the fields. This will prevent any duplicate values for userid too.

Warning - To create the  unique index in the database, you must ensure that there are already no duplicate records for user id in the table. If there are duplicate records, then the index will not be created in the underlying database and hence, the duplicate check wont work.

Read only

0 Kudos
1,608

Thank you , Now it is working fine. But during Activation i got some warning message while activating index. could you please explain about it ?

Read only

0 Kudos
1,608

You probably have both the fields as primary key and the unique index created on one of the fields

If you have cell_id defined as primary key in the table, then you don't have to create a unique index for that same field, since an index already exists for that.

When you try to create an index with the same fields as the primary keys of the table, or a subset of the primary key fields, the above error will come.

Mark only one of the field cell or user id as primary key in the table, and the other field as the unique index. (You may need to go to SE14 and adjust and activate table when un-marking one of the fields as primary. )

Read only

0 Kudos
1,608

Now i Understood clearly , Thank you so much

Read only

former_member187692
Participant
0 Kudos
1,608

Hi,

     Try giving same cell no and same "USER ID" as well (since both a keys). Then it'll pop a message in the status bar saying 'a data record with the specific key already exists'.

     

As Susmitha said:- if you want only 1 record for every cell number make only "CELL NO" field as primary field.

Hope you understand the concept of primary key in this context.

Regards,

Krishna.

Read only

thangam_perumal
Contributor
0 Kudos
1,608

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

Read only

0 Kudos
1,608

I understood . Thanks for your reply. But is there any option to check for both filed to have unique value ?