drop the supplied table using dynamic SQL.
SQL>
SQL> CREATE OR REPLACE PROCEDURE DropTable(p_Table IN VARCHAR2) AS
2 sqlString VARCHAR2(100);
3 v_Cursor BINARY_INTEGER;
4 v_ReturnCode BINARY_INTEGER;
5 BEGIN
6 sqlString := 'DROP TABLE ' || p_Table;
7
8 v_Cursor := DBMS_SQL.OPEN_CURSOR;
9
10 DBMS_SQL.PARSE(v_Cursor, sqlString, DBMS_SQL.NATIVE);
11 v_ReturnCode := DBMS_SQL.EXECUTE(v_Cursor);
12
13 DBMS_SQL.CLOSE_CURSOR(v_Cursor);
14 END DropTable;
15 /
Procedure created.
SQL> show errors
No errors.
SQL>
SQL> CREATE OR REPLACE PROCEDURE DropTable(p_Table IN VARCHAR2) AS
2 sqlString VARCHAR2(100);
3 BEGIN
4 sqlString := 'DROP TABLE ' || p_Table;
5
6 EXECUTE IMMEDIATE sqlString;
7 END DropTable;
8 /
Procedure created.
SQL>
SQL> show errors
No errors.
SQL>
SQL>
Related examples in the same category