无法在 Oracle 的存储过程中创建临时 table

Not able to create temp table in stored procedure in Oracle

我正在尝试在 Oracle 中创建临时 table。

我在 SQL 服务器上是这样做的:

IF object_id('tempdb..#qcCSTemp') IS NOT NULL   
BEGIN
    DROP TABLE #qcCSTemp
END

我想要 Oracle 中的类似功能。我试过这段代码:

create global temporary table temptable (mgr number);

但是我得到一个错误:

Error(32,7): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge

请指教

提前致谢。

begin
      create global temporary table temptable (mgr number);
    end;
    /

ORA-06550:第 2 行,第 3 列: PLS-00103:在期望以下之一时遇到符号 "CREATE":

( begin case declare exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open 回滚 保存点设置 sql 执行所有合并管道清除的提交

    begin
      execute immediate 'create global temporary table temptable (mgr number)';
   execute immediate 'insert into   temptable select pct_free from dba_tables';
   execute immediate 'insert into   temptable  values(-99)'; 
    end;
    /

4 / PL/SQL 程序成功完成

select count(*) from temptable;

     0