-----------------------------------------------------------------
-- PL/SQL: DBMS_SQL Package - Executing drop/create statement   -
--         (Section 4.9.2)                                      -
-- Chapter 4; Oracle Programming -- A Primer                    -
--            by R. Sunderraman                                 -
-----------------------------------------------------------------

DECLARE
  handle INTEGER;
  stmt1 varchar2(256);
  stmt2 varchar2(256);
BEGIN

  stmt1 := 'drop table zzz';
  stmt2 := 'create table zzz (col1 integer,' ||
           ' col2 number(4), col3 varchar2(30))';
  handle := DBMS_SQL.OPEN_CURSOR;
  DBMS_SQL.PARSE(handle,stmt1,DBMS_SQL.V7);
  dbms_output.put_line('Table ZZZ dropped');
  DBMS_SQL.PARSE(handle,stmt2,DBMS_SQL.V7);
  dbms_output.put_line('Table ZZZ created');
  DBMS_SQL.CLOSE_CURSOR(handle);

  EXCEPTION
    WHEN OTHERS THEN
      DBMS_SQL.CLOSE_CURSOR(handle);
END;
/
