9.3. Selecting from UPDATE, DELETE, and INSERT

While the INSERT, UPDATE, and DELETE statements change data in the specified tables, they only return a message indicating whether the statement completed successfully. If the statement completed successfully, you need to issue a separate SQL statement to find out what changed. In the next example, to determine which rows are to be deleted, you first issue a SELECT statement to capture the rows you will delete on the following DELETE statement. Both statements have the same WHERE condition to filter the same rows.

					SELECT empno, firstnme, lastname FROM employee WHERE workdept = 'A00';
					DELETE FROM employee WHERE workdept = 'A00';
				

Rather than issuing two separate statements, they can be optimized ...

Get Understanding DB2®: Learning Visually with Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.