sql >> Base de Datos >  >> RDS >> Oracle

¿Cómo usar la tabla temporal global de Oracle?

Pruebe lo siguiente usando ejecutar inmediatamente:usa un controlador de excepciones para omitir si la tabla ya existe; también tenga en cuenta que no puede usar SQL select dentro de PLSQL

DECLARE
  l_column1 number;
begin
  begin
    execute immediate 'create global temporary table my_temp_table(column1 number) 
on commit   preserve rows';
  exception when others
    then
    dbms_output.put_line(sqlerrm);
  end;
  insert into my_temp_table (column1) values (1);
  select * into l_column1 from my_temp_table where column1=1;
  dbms_output.put_line('the temp value is '||l_column1);   
end;