首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

oracle存储过程解决方案

2013-03-26 
oracle存储过程创建一个存储过程,要求判断数据库中的XM_XXK表中是否存在记录,如果存在记录立即清空表中的

oracle存储过程
创建一个存储过程,要求判断数据库中的XM_XXK表中是否存在记录,如果存在记录立即清空表中的记录,然后从另外一个数据库把数据迁移到该表上。
[解决办法]
写个大概:

create or replace procedure copy_data
is
  vn_cnt number(4) := 0;
begin
 select count(*) into vn_cnt from XM_XXK;
 if vn_cnt <> 0 then
   delete from XM_XXK;
 end if;
   insert into XM_XXK as select * from XM_XXX@db_link; --db_link是另外一个数据库的DBLINK;
   commit;
end;

[解决办法]
改一下一楼的.

create or replace procedure copy_data
is
  vn_cnt number(4) := 0;
begin
 select count(*) into vn_cnt from XM_XXK;
 if vn_cnt <> 0 then
   truncate table XM_XXK; --此次避免多次执行后生成高水位线,降低查询速度.
 end if;
   insert into XM_XXK as select * from XM_XXX@db_link; --db_link是另外一个数据库的DBLINK;
   commit;
end;

热点排行