2006 Dec 15 11:13 AM
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 cant 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,
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 cant 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
2006 Dec 15 11:20 AM
Hi Vidya,
Strictly speaking we cannot do that. That is the concept of primary key to have only one unique key. Is that standard table ? if it is so then check whether it has secondary keys along with the primary key which is calle das composite key, If this is the case then the database table will check for the entire composite key.
Let me know whether you understood this or not
Reward points if it is helpful.
Regards,
Kiran I
2006 Dec 15 11:40 AM
Hi ,
This is not possible , beacuse it ruins the basic purpose of having a primary key if we can have multiple entries with the same primary key.
Discuss the same with the client , may be this can be an error in the excel file.
Regrads
Arun
2006 Dec 15 11:45 AM
There may be 2 primary keys in that table , though one of them is duplicated the other one may be ubique
Primary key1 Primary key2
111 abc
222 abc
2006 Dec 15 2:19 PM
You can't rely on the spreadsheet supplied by the customer. You have to look at the data (SE11 or SE16).
Rob
2006 Dec 17 6:51 AM
Hi,
Just make one more unique field as a part of primary key. That will solve your problem. (If you can do that?)
Example
Table1
F1(pk) -
F2(pk)------ F3 -
F4
1 -
1 -
1 -
A
1 -
1 -
2 -
B
You can make field F3 also part of the primary key (If thats possible).
Or
Data may be wrong. Primary keys in RDBMS are based on set theory. By definition set is a collection of unique elements. So it cannot be possible
Regards,
Vinay
2006 Dec 17 7:07 AM
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
2006 Dec 17 12:36 PM
Hi Vidya,
Without adding additional fields into the DB Table, this would not be possible.
Regards,
Ramki.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |