‎2009 Apr 20 10:36 AM
Hi All ,
I have to insert a given number of records in a database table.
Database table has DATE and TIME as P-key.
Issue : Suppose there are 500 records.In such a case INSERT does not work on the table due to insertion at same TIME.Hence only limited number of records are inserted in table.
Please provide solution such that the database table is updated with all the records.I do not want to use WAIT UP TO 1 SECONDS.
Thanks in Advance.
‎2009 Apr 20 10:42 AM
Hi,
You can use Modify statement.
I think it should work.
Thanks,
Archana
‎2009 Apr 20 10:44 AM
Hi Archana ,
I need to insert a new record in the database table and not to modify the existing record.
‎2009 Apr 20 10:52 AM
Hi,
Try this.
Suppose you have 500 entries in the Internal table.
data : lv_time type sy-uzeit.
loop at itab.
if sy-tabix = 1.
lv_time = sy-uzeit.
else.
lv_time = lv_time + 1.
endif.
itab-time = lv_time.
modify itab index sy-tabix.
endloop.
modify ztable from itab.
Hope this solves your problem.
Thanks & Regards,
Bhupal
‎2009 Apr 20 11:02 AM
Database table has DATE and TIME as P-key.If Time field is a Primary key, how can you update with same value for every record
‎2009 Apr 20 11:10 AM
A more reasonable way is, to add a third key in the table, e.g. SERIAL_NUMBER.
In an update, for example, 500 records:
First, select db by DATE+TIME, to get the maximum SERIAL_NUMBER;
Then, assign a SERIAL_NUMBER , sequentially, to each of your 500 records.
Finally, update db by DATETIMESERIAL_NUMBER.
‎2009 Apr 20 4:55 PM
loop at the entries table from where you want to update and in that loop use insert statement.
loop at itab into wa.
update dbtab using wa.
endloopcommit work after this.
Also there is no harm if date and time is the key field. you can have unique entries based on it.
Regards,
Lalit Mohan Gupta.