drop table  DropTableName.OBJECT_NAME;
改成
execute immediate 'drop table '||DropTableName.OBJECT_NAME;

解决方案 »

  1.   

    直接执行是不行的,用下面的试试:SQL_STR = 'drop table '|| DropTableName.OBJECT_NAME ;
    EXECUTE IMMEDATE SQL_STR;
      

  2.   

    用oracle的内部存储过程包dbms_sql构造sql,然后执行。见下面的例子(摘自sql programing)PROCEDURE drop_object
    (object_type_in IN VARCHAR2, object_name_in IN VARCHAR2)
    IS
    cursor_id INTEGER;
    BEGIN
    /*
    || Open a cursor which will handle the dynamic SQL statement.
    || The function returns the pointer to that cursor.
    */
    cursor_id := DBMS_SQL.OPEN_CURSOR;
    /*
    || Parse and execute the drop command which is formed through
    || concatenation of the arguments.
    */
    DBMS_SQL.PARSE
    (cursor_id,
    'DROP ' || object_type_in || ' ' || object_name_in,
    DBMS_SQL.NATIVE);
    /* Close the cursor. */
    DBMS_SQL.CLOSE_CURSOR (cursor_id);
    EXCEPTION
    /* If any problem arises, also make sure the cursor is closed. */
    WHEN OTHERS
    THEN
    DBMS_SQL.CLOSE_CURSOR (cursor_id);
    END;
      

  3.   

    如果是oracle8.0.5以前的版本,不支持execute immediate用法,需要使用楼上的方法