Manipulating Data in a DB2 Server for VM Table

There are SQL data manipulation statements that let you insert new rows into tables or delete or update existing rows. Here are the three data manipulation statements:
  • INSERT lets you insert one new row into a given table. Also, by using the SELECT clause, you can insert several new rows selected or computed from other tables. You can insert data into any table you create. You can also insert data into another user's table, if you have INSERT privilege on that table.
    For example, in a FORTRAN application, the statements:
          EXEC SQL INSERT INTO NLIST
         1  SELECT LNAME,FNAME,SERIALNO
         2  FROM NAMELIST
         3  WHERE SERIALNO = :EMPSER

    inserts into table NLIST columns LNAME, FNAME, and SERIALNO of all the rows of table NAMELIST having the SERIALNO column equal to the value in the host variable EMPSER.

  • DELETE deletes one or more rows from a given table. However, first you must specify a selection criterion (WHERE clause). See Defining Search Conditions for details on defining search conditions. Otherwise, the DELETE statement deletes all table rows and sets a warning indicator (SQLWARN4). You can test the value of SQLWARN4 and, in case of error, issue the ROLLBACK WORK command. You can delete rows from any table you create. You can also delete data from another user's table, if you have DELETE privilege on that table.
    For example, in a FORTRAN application, the statement:
          EXEC SQL DELETE FROM NAMELIST WHERE SERIALNO = :EMPSER
    deletes the row or rows having the SERIALNO column equal to the value in the host variable EMPSER.

    You can also delete the row that the current cursor points to by specifying WHERE CURRENT OF cursor-name.

  • UPDATE changes the value of one or more fields in a table. You can update rows in any table you create. You can also update data in another user's tables, if you have the UPDATE privilege on the columns of that table.

    You can also change the value of one or more fields in a table by specifying WHERE CURRENT OF cursor-name.