title: Create global temporary table within stored procedures in Oracle
body: <p>I am an experienced SQL Server programmer but new to Oracle. I want to write a stored procedure. The first thing I want to do is to create a <em>Global Temporary Table</em>, which I will then populate and finally return the results (I have done this many times in SQL Server).</p>
  
  <p>Here's the skeleton of what I have. Oracle complains. Can somebody tell me why and what to do about it? (I have created a Global Temporary Table outside of the stored procedure and it works as expected)</p>
  
  <p>Thanks,</p>
  
  <p>Dick</p>
  
  <pre><code>create or replace PROCEDURE usp_MU_Secure_Msg_Rpt (startdate IN varchar2, enddate IN varchar2)
  
  IS
  
  BEGIN
  
  CREATE GLOBAL TEMPORARY TABLE Denominator_pvids
  
  (pvid number (38,0),
  
  searchname varchar2 (78),
  
  no_distinct_pids integer,
  
  no_secure_messages integer)
  
  ON COMMIT DELETE ROWS;
  
  
  --SQL to populate table goes here
  
  
  SELECT * FROM Denominator_pvids
  
  
  END;
  </code></pre>