EXECUTE IMMEDIATE USING IN : Execute immediate « PL SQL Statements « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE employee(
  2       employee_id VARCHAR2(3) PRIMARY KEY,
  3       first_name  VARCHAR2(15),
  4       last_name   VARCHAR2(20),
  5       hire_date   DATE
  6       );

Table created.

SQL>
SQL>
SQL> CREATE OR REPLACE PROCEDURE run_9am_procedure (
  2     id_in     IN   employee.employee_id%TYPE,
  3     hour_in   IN   INTEGER
  4  )
  5  IS
  6     v_apptcount   INTEGER;
  7     v_name        VARCHAR2 (100);
  8  BEGIN
  9     EXECUTE IMMEDIATE 'BEGIN '
 10                       || TO_CHAR (SYSDATE, 'DAY')
 11                       || '_set_schedule (:id, :hour, :name, :appts); END;'
 12        USING IN id_in, IN hour_in, OUT v_name, OUT v_apptcount;
 13
 14     DBMS_OUTPUT.put_line (v_name|| ' has '|| v_apptcount|| ' appointments on '|| TO_CHAR (SYSDATE));
 15  END;
 16  /

Procedure created.

SQL>
SQL> drop table employee;

Table dropped.

SQL>
SQL>








22.16.Execute immediate
22.16.1.Simple EXECUTE IMMEDIATE
22.16.2.Call EXECUTE IMMEDIATE in Pl/SQL block
22.16.3.Execute sql statement in a procedure
22.16.4.'execute immediate in' action
22.16.5.Define a procedure to drop a database object
22.16.6.Create a function to count table row
22.16.7.Use procedure to create an index dynamically
22.16.8.Call function and get result by using 'EXECUTE IMMEDIATE'
22.16.9.EXECUTE IMMEDIATE dynamic sql to alter session
22.16.10.Use 'execute immediate' to run a insert statement
22.16.11.select into rowtype then use it in 'execute immediate'
22.16.12.Quotation string
22.16.13.Use 'EXECUTE IMMEDIATE' to execute an update statement
22.16.14.Wrap 'EXECUTE IMMEDIATE' for current user
22.16.15.Wrap statement with 'BEGIN...END'
22.16.16.Catch exception from 'EXECUTE IMMEDIATE'
22.16.17.EXECUTE IMMEDIATE USING IN
22.16.18.Drop user, create user and grant permission with PL/SQL code
22.16.19.execute immediate into
22.16.20.Update row with 'execute immediate'