2008 Jun 04 11:19 AM
Hi guys,
I need to insert new records into my db table if they do not exist or update records if they dont exist in the table.
Am using a modify statement .But this is taking 10 times more time than insert stmnt.
Is there any way to avoid modify stmnt and still implement my logic
Thanks
Hi guys,
I need to insert new records into my db table if they do not exist or update records if they dont exist in the table.
Am using a modify statement .But this is taking 10 times more time than insert stmnt.
Is there any way to avoid modify stmnt and still implement my logic
Thanks
2008 Jun 04 11:26 AM
Hi,
You can do it this way :
Loop the internal table and check in your DB table if the record exist. <You do this by taking DB table record in another internal table and then reading this table. >.
If there is a record, use update statement else use insert statelemt.
This should solve your problem.
Regards,
Lalit Kabra
2008 Jun 04 11:27 AM
hi,
Apart from using the MODIFY statement, the content of an individual table line can be changed using assignments to field symbols and dereferenced data references that point to the table line.
2008 Jun 04 11:29 AM
try to use the statement like this:
modify <dbtab> from table itab.
This is faster and good in performance. Only thing is that your itab structure should be same as that of your database table.
2008 Jun 04 11:34 AM
Hi,
MODIFY itab - itab_line TRANSPORTING comp1 comp2 ...
MODIFY itab - itab_lines itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.
Even above 2 stmts improves can improve performance.
Edited by: Prince on Jun 4, 2008 12:35 PM
2008 Jun 04 11:54 AM
Hi Prince ,
Couldnt understand.Could you be a little more explicit.
Thanks a lot
Others please help too
2008 Jun 04 12:01 PM
True, Prince used to be more explicit back in the Eighties...
In this case he's on the wrong trip, because you are talking about DB update, while he is referring to internal table operations.
Sometimes your program logic already allows you to collect the data in separate internal tables XXX_INS and XXX_UPD, which you can then use to perform the INSERT and UPDATE statements. This would be the most effective way.
I've seen people using an INSERT ... ACCEPTING DUPLICATE KEYS and then UPDATE the entire data, which is quite quick and dirty.
Greetings
Thomas
2008 Jun 04 12:20 PM
Hi ankit!
For the scenerio that u ahve mentioned
there are two options either u use modify statement(do F1 on modify u will get all syntax related to it) else u can check ur itab if it has records.
If the records exists then use insert else use update.
rewrd if useful.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |