‎2007 Jun 26 11:46 AM
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.
‎2007 Jun 26 11:49 AM
Hi,
Instead of UPDATE use MODIFY statement.Now this statement will modify only the field u required.
Regards,
Nagaraj
‎2007 Jun 26 11:50 AM
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
‎2007 Jun 26 11:50 AM
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
‎2007 Jun 26 11:53 AM
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.
‎2007 Jun 26 12:00 PM
Hi...
Use Modify statement to update the database table by putting that statement in loop throught proper condition.
Regards
--
Sasidhar Reddy Matli.