Adding Records to a Database Table

Add a single record to a database table

insert into <database table> values <work area>


tables: mytable.
mytable-number = 1.
mytable-name = 'John'.
insert into mytable values mytable.

Inserting all lines from an internal table into a database table:

insert <database table> from table <internal table>

You can add the option: accepting duplicate keys

If you add accepting duplicate keys you can test if the table was successfully updated, else a runtime error wil be generated.

Note: accepting duplicate keys does not mean that duplicate keys will be accepted, only that it is possible to test on sy-subrc if you have tried to insert records with duplicate keys. All remaining records will be inserted.

After you have inserted the recors the variable sy-dbcnt contains the number of records that were inserted.

Converted from CHM to HTML with chm2web Standard 2.7 (unicode)