title: Temp table is not a known variable
body: <p>I've got a temp table which I want to use twice to insert into it:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION test1(user_id BIGINT) RETURNS BIGINT AS
  $BODY$
  BEGIN
    DROP TABLE IF EXISTS temp_table1;
    create temp table temp_table1
    on commit drop
    as select * from get_some_data($1); -- try to get the data for the 1st time
  
    if not exists (select * temp_table1) then
      select try_to_update_data($1); -- updates data, returns void
    end if;
  
    -- try to get the data again
    select * into temp_table1 from get_some_data($1); -- error!
    if not exists (select * from temp_table1) then
      return 0;
    end if;
  
    --........ use temp_table1
  </code></pre>
  
  <p>It trows the error: </p>
  
  <pre><code>ERROR:  "temp_table1" is not a known variable
  </code></pre>
  
  <p>How do I solve this?</p>