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

diff b/w Insert, Update, Modify

Former Member
0 Likes
13,419

Hi Experts,

can anyone give me a detailed differences b/w Update, Insert n Modify commands in Databs Tables along with the use of commit statement in all ...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,193

hi,

Insert: inserts new record in the database

update : updates the existing record int he database, if that particular record is not there it give error.

Modify : modifies a record in the database , if that particular record is not there then a new record is added into the databse.

use of Insert in different ways:

Insert into a database table

- INSERT INTO dbtab [CLIENT SPECIFIED] VALUES wa.

INSERT INTO (dbtabname) [CLIENT SPECIFIED] VALUES wa.

- INSERT dbtab [CLIENT SPECIFIED].

INSERT *dbtab [CLIENT SPECIFIED].

INSERT (dbtabname) [CLIENT SPECIFIED] ... .

- INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab.

INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab.

Insert into an internal table

- INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx].

INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2

[INDEX idx3].

Insert into a field group

- INSERT f1 f2 ... INTO fg.

Insert a program

- INSERT REPORT prog FROM itab.

Insert text elements

- INSERT TEXTPOOL prog ...FROM itab ...LANGUAGE lg.

Modify:

Change a database table

- MODIFY dbtab.

MODIFY *dbtab.

MODIFY (dbtabname) ... .

- MODIFY dbtab FROM TABLE itab.

MODIFY (dbtabname) FROM TABLE itab.

- MODIFY dbtab VERSION vers.

MODIFY *dbtab VERSION vers.

Change an internal table

- MODIFY itab [FROM wa] [INDEX idx].

Change a list line

- MODIFY LINE n.

- MODIFY LINE n OF CURRENT PAGE.

- MODIFY LINE n OF PAGE m.

- MODIFY CURRENT LINE.

Change the attributes of a screen field

- MODIFY SCREEN.

Update:

1. UPDATE dbtab SET s1 ... sn.

2. UPDATE dbtab. or

UPDATE *dbtab. or

UPDATE (dbtabname) ... .

3. UPDATE dbtab FROM TABLE itab. or

UPDATE (dbtabname) FROM TABLE itab.

5 REPLIES 5
Read only

Former Member
0 Likes
6,193

Hi

MODIFY

... FROM { {wa} | {TABLE itab} }.

1. ... FROM wa

2. ... FROM TABLE itab

A wa data object that is not table-type or an itab internal table can be specified after FROM. On the one hand the content of the data objects determines whether the line(s) are inserted or changed, and on the other hand, which values are inserted or used for changes.

INSERT

... { {VALUES wa}

| {FROM wa|{TABLE itab [ACCEPTING DUPLICATE KEYS]}} }.

1. ... {VALUES wa} | {FROM wa} ...

2. ... FROM TABLE itab [ACCEPTING DUPLICATE KEYS] ...

After FROM and VALUES, you can specify a non-table-type data object wa. After FROM, you can also specify an internal table itab. The contents of the row(s) to be inserted are taken from these data objects

UPDATE

... { {SET set_expression [WHERE sql_cond]}

| {FROM wa|{TABLE itab}} }.

1. ... SET set_expression [WHERE sql_cond]

2. ... FROM wa

3. ... FROM TABLE itab

The specifications in source define which rows and columns are changed. Either individual columns are changed using the addition SET or entire rows are overwritten using the addition FROM.

After FROM, either a non-table-type data object wa or an internal table itab can be specified. The content of these objects determines - on the one hand - which row(s) is/are changed, and - on the other hand - which values are used to overwrite the row(s).

Check out these related threads

Reward points if useful

Regards

Anji

Read only

Former Member
0 Likes
6,193

Hi Rohit ,

The diffrence is as below.

1. Update : Tries to update a record in the database , if such a record is not found an error is generated.

2. Insert : Inserts a new record in the database.

3. Modify : Tries to modify a records in the database , if such a record is not found then a new records is inserted into the databse.

Commit statement is used to commit the work and finsh the Logical Unit of Work(LuW) and hence update the database.

Regards

Arun

Read only

Former Member
0 Likes
6,193

hi

<b>Upadte</b>: If the key record is existing in the DBtable the key record will update success fully then sy-subrc will eq 0 or else update fails and sy-subrc will non-zero.

<b>Modify</b>: if the key record is existing in the DBtable then the the record will update/modify else if the key record is not existing then it will insert the new record

in dbtable.

<b>'Insert'</b> will add a new record or a new row into the database table.

<b>A COMMIT statement</b> ( commit_statement) terminates the current transaction and starts a new one <commit_statement> ::= COMMIT [WORK]

The commit statement terminates the current transaction. This means that the modifications executed within the transaction are recorded and are thus visible to concurrent users as well.

The COMMIT statement implicitly opens a new transaction. Any locks set within the new transaction are assigned to this transaction.

Also check these links

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Read only

Former Member
0 Likes
6,194

hi,

Insert: inserts new record in the database

update : updates the existing record int he database, if that particular record is not there it give error.

Modify : modifies a record in the database , if that particular record is not there then a new record is added into the databse.

use of Insert in different ways:

Insert into a database table

- INSERT INTO dbtab [CLIENT SPECIFIED] VALUES wa.

INSERT INTO (dbtabname) [CLIENT SPECIFIED] VALUES wa.

- INSERT dbtab [CLIENT SPECIFIED].

INSERT *dbtab [CLIENT SPECIFIED].

INSERT (dbtabname) [CLIENT SPECIFIED] ... .

- INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab.

INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab.

Insert into an internal table

- INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx].

INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2

[INDEX idx3].

Insert into a field group

- INSERT f1 f2 ... INTO fg.

Insert a program

- INSERT REPORT prog FROM itab.

Insert text elements

- INSERT TEXTPOOL prog ...FROM itab ...LANGUAGE lg.

Modify:

Change a database table

- MODIFY dbtab.

MODIFY *dbtab.

MODIFY (dbtabname) ... .

- MODIFY dbtab FROM TABLE itab.

MODIFY (dbtabname) FROM TABLE itab.

- MODIFY dbtab VERSION vers.

MODIFY *dbtab VERSION vers.

Change an internal table

- MODIFY itab [FROM wa] [INDEX idx].

Change a list line

- MODIFY LINE n.

- MODIFY LINE n OF CURRENT PAGE.

- MODIFY LINE n OF PAGE m.

- MODIFY CURRENT LINE.

Change the attributes of a screen field

- MODIFY SCREEN.

Update:

1. UPDATE dbtab SET s1 ... sn.

2. UPDATE dbtab. or

UPDATE *dbtab. or

UPDATE (dbtabname) ... .

3. UPDATE dbtab FROM TABLE itab. or

UPDATE (dbtabname) FROM TABLE itab.

Read only

Former Member
0 Likes
6,193

Thanx all, all useful answered has been rewarded......