UPDATE
and DELETE
statements should contain WHERE
clauses to keep the modification of records under control.
Otherwise unexpected data loss could result.
Noncompliant code example
DECLARE
maxAge PLS_INTEGER := 60;
BEGIN
UPDATE employee SET status = 'retired'; -- Noncompliant - the WHERE was forgotten
END;
/
Compliant solution
DECLARE
maxAge PLS_INTEGER := 60;
BEGIN
UPDATE employee SET status = 'retired' WHERE age > maxAge;
END;
/