Update value and return affected row count : Update « PL SQL Programming « Oracle PL/SQL Tutorial






SQL> CREATE OR REPLACE FUNCTION updNVal (
  2     tab IN VARCHAR2,
  3     col IN VARCHAR2,
  4     val IN NUMBER,
  5     whr IN VARCHAR2 := NULL,
  6     sch IN VARCHAR2 := NULL)
  7     RETURN INTEGER
  8  IS
  9  BEGIN
 10     EXECUTE IMMEDIATE
 11        'UPDATE ' || NVL (sch, USER) || '.' || tab ||
 12        '   SET ' || col || ' = :the_value
 13          WHERE ' || NVL (whr, '1=1')
 14       USING val;
 15     RETURN SQL%ROWCOUNT;
 16  END;
 17  /

Function created.

SQL>
SQL>
SQL>








24.11.Update
24.11.1.How DML works with PL/SQL
24.11.2.UPDATE statement with variable
24.11.3.Update value and return affected row count
24.11.4.Use update statement in stored procedure
24.11.5.Use cursor variable in update statement
24.11.6.Procedure for adjust salary
24.11.7.Update returning into
24.11.8.Update salary with stored procedure
24.11.9.Update table and return if success