Code Listing 4: Binding in those variable values

CREATE OR REPLACE PROCEDURE date_range_col_update (
   tab_in       IN   VARCHAR2
  ,datecol_in   IN   VARCHAR2
  ,start_in     IN   DATE
  ,end_in       IN   DATE
  ,valcol_in    IN   VARCHAR2
  ,val_in       IN   NUMBER
)
IS
   str   VARCHAR2 (32767)
      :=    'UPDATE '
         || tab_in
         || ' SET '
         || valcol_in
         || ' = :val WHERE '
         || datecol_in
         || ' BETWEEN :lodate AND :hidate';
BEGIN
   EXECUTE IMMEDIATE str
               USING val_in, start_in, end_in;

   DBMS_OUTPUT.put_line ('Rows updated: ' || TO_CHAR (SQL%ROWCOUNT));
-- Exception handled left out to save space
END date_range_col_update;
/

-- Sample invocation of procedure
BEGIN
   date_range_col_update (
      'emp', 'hiredate', sysdate-100, sysdate, 'sal', 10000);
END;