WEB开发网
开发学院数据库Oracle oracle的存储过程里怎样调用动态变量 阅读

oracle的存储过程里怎样调用动态变量

 2007-05-13 12:30:45 来源:WEB开发网   
核心提示:create or replace procedure SYSRINGALL_TEST isall_tmp_name char(30);all_name char(30);beginif all_tmp_name is null thenselect 'ring_all_old_'||to_char(s
create or replace procedure SYSRINGALL_TEST is
all_tmp_name char(30);
all_name char(30);
begin
if all_tmp_name is null then
select 'ring_all_old_'||to_char(sysdate,'yyyymm')||'_tmp' into all_tmp_name from dual;
end if;
if all_name is null then
select 'ring_all_old_'||to_char(sysdate,'yyyymm') into all_name from dual;
end if;
------由ALL进TMP---------
insert into all_tmp_name
select * from all_name;
commit;
end SYSRINGALL_TEST;

==========================

其实就是想动态生成ring_all_old_200606和ring_all_old_200606_tmp

这两个表名让下面使用

但老是编译出错,如果把下面改成

insert into ring_all_old_200606_tmp

select * from ring_all_old_200606;

就能编译通过.

请问该怎样改啊?

create or replace procedure SYSRINGALL_TEST is
all_tmp_name char(30);
all_name char(30);
tmp_str varchar(2000);
begin
if all_tmp_name is null then
select 'ring_inkfish_'||to_char(sysdate,'yyyymm')||'_tmp' into all_tmp_name from dual;
end if;
if all_name is null then
select 'ring_inkfish_'||to_char(sysdate,'yyyymm') into all_name from dual;
end if;
tmp_str :='insert into '||all_tmp_name||' select * from '||all_name;
execute immediate tmp_str;
commit;
end SYSRINGALL_TEST;

嘿嘿,不容易啊!!自己搞定啦!希望能对大家有帮助!

Tags:oracle 存储 过程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接