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

Query regarding UPDATE

Former Member
0 Likes
643

Hi All,

I have one query regarding UPDATE.

If I want to update only one field of a database table from my internal table..what is preferable & Why in terms of performance, standards ?

(1) Loop at internal table. update the database table with SET statment.

Problem: Multiple database touch.

(2) update the database table with internal table at one go, with use of UPDATE statement.

Problem: I am updating all fields even if I want to update only one field.

Regards,

Siddhesh Sanghvi.

5 REPLIES 5
Read only

former_member404244
Active Contributor
0 Likes
600

Hi,

Instead of UPDATE use MODIFY statement.Now this statement will modify only the field u required.

Regards,

Nagaraj

Read only

Former Member
0 Likes
600

Hi

First fetch the data from DB table into internal table

loop that itab.

modify that field in itab

endloop.

use modify statement to update the db table

MODIFY DB from table ITAB.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
600

Hi

It is preferred to loop at internal table and update the table field.

Loop at itab.

Update TABLE <table> set field = value..... where <condition>

Endloop.

<b>Second option is not preferred</b>.

Regards

Raj

Read only

Former Member
0 Likes
600

Hi Siddhesh,

In case of UPDATE statement it is always advisable to UPDATE the data at one go itself, rather than making it inside the loop.

However, when you want to update any of the primary key fields of the database table, you will always have to use the UPDATE with SET addition inside a loop.

So, basically, your problem depends on the requirement. Please see if you can use the UPDATE at one go depending on the fields to be updated.

Read only

Former Member
0 Likes
600

Hi...

Use Modify statement to update the database table by putting that statement in loop throught proper condition.

Regards

--

Sasidhar Reddy Matli.