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 IN A DBTAB USING A SQL SENTENCE

Former Member
0 Likes
519

Hi,

I need to insert in a dbtab from other dbtab. I would like use a sql sentence like this:

insert into dbtab2 (c1,c2)

select c1,sum(c2)

from dbtab1

group by c1,c2.

How can I do it ?

(I can´t use internal tables because its size is very big (more than 2 Gb). If I use internal tables, the process "crash" with error SYSTEM_IMODE_TOO_LARGE)

Thanks

1 ACCEPTED SOLUTION
Read only

faisalatsap
Active Contributor
0 Likes
487

Hi Oscar Alconchel

Try the following code hope this will help you in this way, only assign the value to Work Area and then from this work area update the dbtable.

TYPES: BEGIN OF t_test,
c1(10) type c,
c2(10) type c,  
END OF t_test.

Data: wa_test type t_test.

Select c1 sum(c2) as c2 
INTO CORRESPONDING FIELDS OF wa_test.
modify dbtable from wa_test.
endselect.

Kind Regards,

Faisal

3 REPLIES 3
Read only

MarcinPciak
Active Contributor
0 Likes
487

Hi,

You can't do this in a single shot, at least with any known to me way. Anyhow you can do other thing: using se16n download your DB table partially to lets say 10 files. Now write a simple report uploading these files and inserting their rows to next DB table.

Of course I assume you only need to transfer these data somehow so this solution would help.

Regards

Marcin

Read only

faisalatsap
Active Contributor
0 Likes
488

Hi Oscar Alconchel

Try the following code hope this will help you in this way, only assign the value to Work Area and then from this work area update the dbtable.

TYPES: BEGIN OF t_test,
c1(10) type c,
c2(10) type c,  
END OF t_test.

Data: wa_test type t_test.

Select c1 sum(c2) as c2 
INTO CORRESPONDING FIELDS OF wa_test.
modify dbtable from wa_test.
endselect.

Kind Regards,

Faisal

Read only

0 Likes
487

Hi Faisal,

This way is of course correct but Oscar said db table is extremly large. Imagine how this would affect performance (number of access to DB tables + network traffic) if it was moved row by row as you suggested.

Regards

Marcin