How to create and use temporary table in oracle stored procedure?

前端 未结 5 787
挽巷
挽巷 2020-11-30 06:01

I want to create temporary table in stored procedure and access it in the same but I got error that ORA-00942:Table or view does not exists. Following is the pr

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 06:49

    Use this

    Create of replace procedure myprocedure
    is 
       stmt varchar2(1000);
       stmt2 varchar2(1000);
    begin
        stmt := 'create global temporary table temp(id number(10))';
        execute immediate stmt;
        stmt2 := 'insert into temp(id) values (10)';
        execute immediate stmt2;
    end;
    

提交回复
热议问题