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

Difference between

Former Member
0 Likes
1,133

hi! all,

can anybody say me the difference between INSERT, UPDATE, MODIFY commands while performing in Database Table .

Thanks and Regards,

Nagulan

10 REPLIES 10
Read only

former_member609120
Contributor
0 Likes
1,095

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

Read only

Former Member
0 Likes
1,095

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

Read only

Former Member
0 Likes
1,095

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.

Read only

Former Member
0 Likes
1,095

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

Read only

Former Member
0 Likes
1,095

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.

Read only

Former Member
0 Likes
1,095

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.

Read only

prasanth_kasturi
Active Contributor
0 Likes
1,095

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

Read only

Former Member
0 Likes
1,095

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.

Read only

Former Member
0 Likes
1,095

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

Read only

Former Member
0 Likes
1,095

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.