‎2008 Feb 19 6:58 AM
hi! all,
can anybody say me the difference between INSERT, UPDATE, MODIFY commands while performing in Database Table .
Thanks and Regards,
Nagulan
‎2008 Feb 19 7:05 AM
INSERT - Add a new record into the database table.
MODIFY - If record is available it modifies otherwise it wont modify.
UPDATE - If record is available its update the record otherwise it creates a new record.
Reward Points if Helpful
‎2008 Feb 19 7:06 AM
hi,
insert will the add new record into table at any position
update will modify the record into the table if exist if not present it will insert new record
modify will modify existing record only
Edited by: Nandini P on Feb 19, 2008 8:06 AM
‎2008 Feb 19 7:07 AM
Hi
insert----u can insert anywhere in the table by giving the index.
INSERT wa_knc1 INTO it_knc1 INDEX 3.
modify---this will modify the existing record and place the new values.
MODIFY it_knc1 FROM wa_knc1 INDEX 1.
update: this will update in the dtabase table.
‎2008 Feb 19 10:25 AM
Hi,
INSERT:
Effect
Adds new records to a database table (see relational database). You can specify the name of the database table either directly in the program in the form dbtab or at runtime as the contents of the field dbtabname. In either case, the database table must be declared in the ABAP Dictionary. You can only insert data using a view if the view refers to a single table and has the maintenance status "No restriction" in the ABAP Dictionary.
By default, data is only inserted in the current client. However, if you use the CLIENT SPECIFIED addition, you can switch off the automatic client handling. This enables you to enter data for any client in a cross-client table, not just in the client in which you are logged on. In this case, the client field is treated like a normal field to which you can assign a value in the work area.
UPDATE:
Effect
Updates values in a database table (see Relational Databases ). You can specify the name of the database table either directly in the form dbtab or at runtime as contents of the field dbtabname. In both cases, the table must be known to the ABAP Dictionary. Normally, lines are updated only in the current client. Data can only be updated using a view if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".
MODIFY :
Effect
Inserts new lines or updates existing lines in a database table (s. relational database). If a line with the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed. You can specify the name of the database table either in the program itself in the form MODIFY dbtab ... or at runtime as the contents of the field dbtabname in the form MODIFY (dbtabname) ... . In both cases, the database table must be defined in the ABAP Dictionary. Normally, records are inserted or updated only in the current client. Data can only be inserted or updated using a view, if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".
MODIFY belongs to the Open SQL command set.
When the statement has been executed, the system field SY-DBCNT contains the number of edited lines.
The return code is set as follows:
SY-SUBRC = 0:
All lines were successfully inserted or updated.
SY-SUBRC = 4:
One or more lines could not be inserted or updated.
Update Modify Insert stmts we use when we want to do some change / Insertion
(1) to database table from internal table or
(2) from work area to internal table.
( AA ) Update
If the intended record in the internal table is found in databse table means it will just update that record.
syntax to update database table from itab:::::
UPDATE dbtab FROM TABLE itab
Changes to lines made with the UPDATE command only becomefinal after a database commit
Without using internal table we can update database table directly as shown below:::::::::::::::::::::
TABLES SFLIGHT.
UPDATE SFLIGHT SET SEATSOCC = SEATSOCC + 3
WHERE CARRID = 'LH' AND
CONNID = '0400' AND
FLDATE = '19950228'.
( BB ) Modify is used to insert new record if the record doesnt exist in datbase table.system check this on primary key basis.
If the intended record in the internal table is found in databse table means it will just update that record.So here its equal to UPDATE stmt.
For changes to database table we use syntax as below ::::
MODIFY DatabaseTable FROM TABLE itab.
For changes to Internal table we use syntax as below ::::
MODIFY itab FROM wa INDEX idx.
[TRANSPORTING f1 ... fn WHERE cond].
( CC ) Insert stmt is used to insert New records into databse table from internal table or to internal table from work area.
By default, data is only inserted in the current client. However, ifyou use the CLIENT SPECIFIED addition, you can switch off theautomatic client handling.
You cannot insert a table line if the table alreadycontains a record with the same primary key.
Syntax::::::::::
INSERT INTO dbtab CLIENT SPECIFIED VALUES wa.
or
INSERT (dbtabname) CLIENT SPECIFIED FROM TABLE itab.
Example
Adding customer "Robinson" to client 002:
TABLES SCUSTOM.
SCUSTOM-MANDT = '002'.
SCUSTOM-ID = '12400177'.
SCUSTOM-NAME = 'Robinson'.
SCUSTOM-POSTCODE = '69542'.
SCUSTOM-CITY = 'Heidelberg'.
SCUSTOM-CUSTTYPE = 'P'.
SCUSTOM-DISCOUNT = '003'.
SCUSTOM-TELEPHONE = '01234/56789'.
INSERT INTO SCUSTOM CLIENT SPECIFIED VALUES SCUSTOM.
Reward if useful.....
Regards,
Chandru
‎2008 Feb 19 5:43 PM
Insert : Inserting the new record.
New data is added to the data base
Update : Updating the already existing record
Here already some data is there, but we are doing
some updates or changes on that data
Modify : Modifying the existing structure.
Data base table has some structure, here we are
adding or deleting or editing that structure.
‎2008 Mar 27 7:38 AM
hi,
Insert : Add a new record or new row into the database table.
Update : If the record is available it updates the record, otherwise it creates a new record.
Modify : If record is available it modifies , otherwise it wont
modify.
‎2008 Mar 27 11:37 AM
INSERT : It inserts a new record into the table.
UPDATE : It updates the existing record in the table.
MODIFY: It works both like insert and update
if record is not present it inserts the record
if record is already there it updates it accordingly
reward if helpful
‎2008 Mar 27 3:53 PM
Hi,
Insert is used to insert the records.
Update is to change the existing records.
Modify is for both insert aswellas update. if the record exists then it will update else it will create.
NOTE: You can use INSERT ,MODIFY for both internal tables and database tables.
Reward if helpful.
Thanks and Regards.
‎2008 Mar 27 6:08 PM
hai nagulan,
INSERT -> is used for insert new recodrds into the database.
UPDATE-> is used to update the existing records which satisfy the condition given by using SET.
MODIFY-> is working as both INSERT + UPDATE functionalities which,
( i ) Creates a new record and insert into database table if no corresponding record exists in it and
( ii ) Change the existing record if the corresponding record exists in the database.
rewards points if it is useful
THANH YOU
PRASAD GVK
‎2008 Mar 27 8:47 PM
Hi,
INSERT - It adds a new record from the internal table into the
database table.
MODIFY - If record is available it modifies in the database
otherwise it wont modify.
UPDATE - If record is available its update the record otherwise it creates a new record and acts as INSERT.
Thanks & Regards,
AMK.
Reward Points if Useful.