‎2009 Jun 25 12:32 PM
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
‎2009 Jun 25 12:35 PM
‎2009 Jun 25 12:41 PM
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
‎2009 Jun 25 12:48 PM
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
‎2009 Jun 25 12:56 PM
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
‎2009 Jun 25 1:05 PM
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.
‎2009 Jun 25 1:02 PM
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..