EXECUTE IMMEDIATE Temp table in oracle does not get created ORA-00942

后端 未结 2 1515
执笔经年
执笔经年 2021-01-21 10:07

Based on this answer I was trying to create temp table, however I am getting exception ORA-00942:table or view does not exist I would assume there is something wron

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 10:16

    'CREATE OR REPLACE GLOBAL TEMPORARY TABLE TempQandA(column1 number) ON COMMIT PRESERVE ROWS';

    The keyword REPLACE is incorrect. You need to simply create the GTT and insert the values into it using EXECUTE IMMEDIATE :

    SQL> BEGIN
      2  EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE Temp_gtt(column1 number) ON COMMIT PRESERVE ROWS';
      3  EXECUTE IMMEDIATE 'insert into temp_gtt(column1) values(1)';
      4  END;
      5  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> select * from temp_gtt;
    
       COLUMN1
    ----------
             1
    
    SQL>
    

提交回复
热议问题