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

Database table Update at same time

Former Member
0 Likes
1,446

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.

6 REPLIES 6
Read only

Former Member
0 Likes
967

Hi,

You can use Modify statement.

I think it should work.

Thanks,

Archana

Read only

0 Likes
967

Hi Archana ,

I need to insert a new record in the database table and not to modify the existing record.

Read only

Former Member
0 Likes
967

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

Read only

former_member222860
Active Contributor
0 Likes
967
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

Read only

Former Member
0 Likes
967

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.

Read only

Former Member
0 Likes
967

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.
endloop

commit 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.