create or replace procedure test as
str_sql varchar2(200);
begin
– 创建临时表
str_sql := ‘create global temporary table temp_table (
fid varchar2(10),
fname varchar2(10)
) on commit preserve rows’;
execute immediate str_sql;
– 使用临时表
str_sql := ‘insert into temp_table(fid, fname) values(’‘a’‘, ‘‘haha’’)’;
execute immediate str_sql;
commit;
dbms_output.put_line(‘Commit:’);
–清楚临时表数据
str_sql := ‘truncate table temp_table’;
execute immediate str_sql;
dbms_output.put_line(‘drop before:’);
commit;
– 删除临时表
str_sql := ‘drop table temp_table’;
execute immediate str_sql;
dbms_output.put_line(‘drop before:’);
commit;
dbms_output.put_line(‘End:’);
end;