‎2008 Jun 04 8:54 AM
hi experts,
i want to know is there any possibility to insert records into a database table with duplicate primary keys.i.e records having same primary key values.
‎2008 Jun 04 9:07 AM
it can be done from ABAP report with addition 'accepting duplicate keys'.
Inserting Several Lines
To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab [ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
‎2008 Jun 04 9:13 AM
hi,
U can use accepting duplicate keys with your insert statement.
Thanks
‎2008 Jun 04 9:20 AM
please be more precise, It is absolutely impossible to insert duplicate keys into a database table!
But you can insert from an internal table which can have duplicate keys into a database table in an efficient way wuithout getting short-dumps.
This is the method with the 'accepting duplicate keys'. It is o.k., if there are not many or nearly no duplicates. It is not recommended if every second record is in fact a duplicate record.
I guess in most cases it is better, to use either 'DELETE ADJACENT DUPLICATES' or a 'COLLECT' to get rid of the duplicates. You must decide first, how you want to proceed with the duplicates, is it irrelevant which record is inserted, would you like to have a sumed up record, or do you have a condition which should be taken?
Siegfried