SQL update clause in a Query is to update a row which is already present in a Table. When you try to update a row and the condition in where clause is not matched, then DB2 returns +100 SQL code.
+100 SQL Code
+100 ROW NOT FOUND FOR FETCH, UPDATE OR DELETE, OR THE RESULT OF A QUERY IS AN EMPTY TABLE.
DB2 UPDATE SQL Query examples
DB2 UPDATE SQL Query with examples. You can update multiple rows.
UPDATE Emp_Table SET Last_Name = 'Srini',
Dept_No = 100,
Salary = 81000
WHERE Employee_No = 123456 ;
When the condition in “WHERE” clause matches, it will modify the row. Else, you will get +100 SQL code.
In SQL when you use SELECT then you need to have FROM clause. This combination is called SELECT – FROMSQL SELECT and UPDATE
Complex Condition in UPDATE
SET Salary = 88000
WHERE Last_Name = 'Srini'
AND First_Name = 'mf' ;
In “WHERE” clause you have two conditions. If matches, it will modify the row. Else, it will not modify it.
UPDATE Query more than 1 Table
SET Salary = 79000
WHERE Employee_No IN (SELECT Employee_No
WHERE dept_no is null) ;
Two tables are using for a matching condition. One is ‘EMP_TABLE’ and the other one is ‘DEPT_TABLE’. When the condition matches, it modifies that particular row.