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

Update Query

Former Member
0 Likes
396

I need to update a z table from a internal table.There are million entries in the table.

Performance wise which one of the two is better.Please note that I need to update only two fileds of the table dbtab.dbtab has 20 fields.

In the first option i'm pulling only two columns in the second select statment.Which forces me to loop to update.

In the second option i'm pulling all the 20 columns in the second select statment.Which gives me the liberty to update in one statement

Appreicate your help

1.

f1 = key

f2 = field to change

SELECT L1 L2

FROM datbone

INTO TABLE itabone

LOOP AT itabone INTO waone

SELECT f1 f2

INTO TABLE itab

package size 10000

FROM dtab

where f3 = waone-L1.

change the field f2 of itab

ENDSELECT

ENDLOOP.

LOOP AT itab INTO wa

UPDATE dbtab SET f2 = wa-f2

ENDLOOP

In the above only the key and

2.

SELECT L1 L2

FROM datbone

INTO TABLE itabone

LOOP AT itabone INTO waone

SELECT *

INTO TABLE itab

package size 10000

FROM dtab

where f3 = waone-L1.

change the field f2 of itab

ENDSELECT

ENDLOOP.

UPDATE dbtab FROM TABLE itab

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
356

How abt this one?

SELECT L1 L2

FROM datbone

INTO TABLE itabone

if not itabone[] is initial.

SELECT *

FROM dtab

INTO TABLE itab

for all entries in itabone

package size 10000

where f3 = itabone-L1.

endif.

UPDATE dbtab FROM TABLE itab.

reward points if it helps

Regards

Gunjan

2 REPLIES 2
Read only

Former Member
0 Likes
357

How abt this one?

SELECT L1 L2

FROM datbone

INTO TABLE itabone

if not itabone[] is initial.

SELECT *

FROM dtab

INTO TABLE itab

for all entries in itabone

package size 10000

where f3 = itabone-L1.

endif.

UPDATE dbtab FROM TABLE itab.

reward points if it helps

Regards

Gunjan

Read only

0 Likes
356

Thanks for your answer.If was wondering since there are million entries is it good to select all the columns of the table?(Since I need to update only one column of the table).Also since there are million entries single update statement will not cause time out?