0% found this document useful (0 votes)
17 views

Modify From

The MODIFY statement in SQL is used to insert or update entries in a database table. It will insert a new entry if the primary key does not already exist, or update the existing entry if the primary key matches. The syntax uses the MODIFY keyword followed by the table name and FROM keyword plus the work area containing the data.

Uploaded by

Vikram Bigamudre
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Modify From

The MODIFY statement in SQL is used to insert or update entries in a database table. It will insert a new entry if the primary key does not already exist, or update the existing entry if the primary key matches. The syntax uses the MODIFY keyword followed by the table name and FROM keyword plus the work area containing the data.

Uploaded by

Vikram Bigamudre
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

MODIFY is the open SQL statement to insert or change entries in the database table.

If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added. If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed. The syntax for the MODIFY statement is as follows. MODIFY <database table> FROM <work area> If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.
DATA: gwa_employee TYPE zemployee. gwa_employee-id gwa_employee-name gwa_employee-place gwa_employee-phone gwa_employee-dept_id = = = = = 6. 'JOSEPH'. 'FRANKFURT'. '7897897890'. 5.

MODIFY zemployee FROM gwa_employee.

ZEMPLOYEE table entries before MODIFY

ZEMPLOYEE table entries after MODIFY

Since there was no entry with the key 6, a new entry was added to the table.
DATA: gwa_employee TYPE zemployee.

gwa_employee-id gwa_employee-name gwa_employee-place gwa_employee-phone gwa_employee-dept_id

= = = = =

6. 'JOHNNY'. 'LONDON'. '7897897890'. 3.

MODIFY zemployee FROM gwa_employee.

Since there was an entry with the key 6, the values in the existing record were modified.

You might also like