Dynamically perform any DDL statements from within your normal PL/SQL processing. : Utility Procedure « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE PROCEDURE exec_ddl
  2     (p_statement_txt VARCHAR2) IS
  3     lv_exec_cursor_num    INTEGER := DBMS_SQL.OPEN_CURSOR;
  4     lv_rows_processed_num NUMBER := 0;
  5     lv_statement_txt      VARCHAR2(30000);
  6  BEGIN
  7     lv_statement_txt := p_statement_txt;
  8     DBMS_SQL.PARSE (lv_exec_cursor_num, lv_statement_txt,
  9        DBMS_SQL.NATIVE);
 10     lv_rows_processed_num := DBMS_SQL.EXECUTE (lv_exec_cursor_num);
 11     DBMS_SQL.CLOSE_CURSOR (lv_exec_cursor_num);
 12  EXCEPTION
 13     WHEN OTHERS THEN
 14        IF DBMS_SQL.IS_OPEN (lv_exec_cursor_num) THEN
 15           DBMS_SQL.CLOSE_CURSOR (lv_exec_cursor_num);
 16        END IF;
 17     RAISE;
 18  END exec_ddl;
 19  /

Procedure created.

SQL>








27.28.Utility Procedure
27.28.1.Don't display lines longer than 80 characters
27.28.2.Create procedure for displaying long text line by line
27.28.3.Procedure create_order
27.28.4.A package to calculate your age
27.28.5.Disable trigger
27.28.6.Returns the total from an order number being passed in.
27.28.7.Dynamically perform any DDL statements from within your normal PL/SQL processing.
27.28.8.Execuate the same SQL in two ways: static way and dynamic way