title: How to create a temporary table inside Stored Procedure before opening a cursor?
body: <p>I'm trying to create a temporary table within a Stored Procedure to perform multiple operations on it and then execute a select statement. I haven't had success using global temporary tables. When I execute the code below I get an <code>ORA-00942 error</code> (table or view does not exists). I must return the cursor to use it in Spring. Any ideas?</p>
  
  <pre><code>PROCEDURE DELETME (
            O_CURSOR         OUT tCursor,
            COD_ERROR        OUT NUMBER,
            MSM_ERROR        OUT VARCHAR2
            )
       AS
  BEGIN
      execute immediate 'create global temporary table my_temp_table(column1 number) on commit delete rows';
       insert into my_temp_table(column1) values (1);
      COD_ERROR := 1;
      OPEN o_cursor FOR
             select * from my_temp_table;
  EXCEPTION 
      WHEN OTHERS THEN
                COD_ERROR:=0;
                MSM_ERROR:=dbms_utility.format_error_backtrace ||' '||SQLERRM;
  END DELETME;
  </code></pre>