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

Insert a high

MusAbaper
Active Participant
0 Likes
618

Hi all,

Can someone tell me how can I do to move the contents of a table (which contains almost 20 000 000 entries) to another one?

I know that i can't use internal table to charge all the entries.

Thank's in advance

Mustapha

6 REPLIES 6
Read only

Former Member
0 Likes
589

could you please be clear with the question?

Read only

0 Likes
589

Thank you Bhargava TC for your response,

I have a specific table who contain a lot of entries (almost 20 000 000 entries) and i want to insert this 20 000 000 entries (with a lot of conditions) in another table, i must try with native SQL (cursor, exec ...) , because as i know, the use of internal table is limited in size ( Internal table can't contains 20 000 000 entries )

What do you think about this ?

Best regards

Read only

former_member189420
Active Participant
0 Likes
589

Hi,

There is an option to fetch the no:of rows from the database table.

So you can do the following.

Select *
From database_table
into itab
where
up to n rows.

read the highest key from the itab and save it in l_highest_key.

update the other database table where you want to copy.

commit work.

do.

Select *
From database_table
into itab
where key > l_highest_key
*up to n rows.*

if sy-subrc ne 0.
exit.
endif.

read the highest key from the itab and save it in l_highest_key.

update the other database table where you want to copy.

*commit work.*

enddo.

Hope this helps.

Thanks & Regards,

Anand Patil

Read only

0 Likes
589

Thanks Anand,

What do you think about this solution ?

DATA :

w_cursor TYPE cursor,

wa_table TYPE table.

OPEN CURSOR w_cursor FOR SELECT *

FROM table

ORDER BY PRIMARY KEY.

DO.

CLEAR wa_table.

FETCH NEXT CURSOR w_cursor INTO wa_table.

IF sy-subrc <> 0.

CLOSE CURSOR w_cursor.

EXIT.

ENDIF.

INSERT table FROM wa_table.

ENDDO.

COMMIT WORK.

Edited by: Mustapha OUHAMOU on Jun 25, 2009 11:56 AM

Read only

0 Likes
589

Hi Musthapha,

The code looks good. Use commit work just after insert. Instead of using it after the loop.

DATA :

w_cursor TYPE cursor,

wa_table TYPE table.

OPEN CURSOR w_cursor FOR SELECT *

FROM table

ORDER BY PRIMARY KEY.

DO.

CLEAR wa_table.

FETCH NEXT CURSOR w_cursor INTO wa_table.

IF sy-subrc 0.

IF sy-subrc ne 0.

CLOSE CURSOR w_cursor.

EXIT.

ENDIF.

INSERT table FROM wa_table.

COMMIT WORK.

ENDDO.

COMMIT WORK.

Read only

Former Member
0 Likes
589

Hi,

If you want to update or insert that huge number of records to a database then, you can segregate it into chunks and send them accordinly..