oracle帮助

1,创建任务

BEGIN
sys.dbms_scheduler.create_job(
job_name => '"INTWORKS"."NEW_AUTOTIME"',
job_type => 'PLSQL_BLOCK',
job_action => 'begin
 new_auto;
 end;',
repeat_interval => 'FREQ=MINUTELY;INTERVAL=600',
start_date => systimestamp at time zone '+8:00',
job_class => 'DEFAULT_JOB_CLASS',
comments => '更新索引',
auto_drop => FALSE,
enabled => true);
END;
 
 
 drop index INTWORKS.NEW_AUTOTIME
 
 sys.dbms_remove('"INTWORKS"."NEW_AUTOTIME"');
 
 
 select * from user_jobs
 begin
 sys.dbms_scheduler.drop_job('"INTWORKS"."NEW_AUTOTM"');
 end; 

2,创建游标

begin
  declare
  cursor CurkeyField is
  select serialno,note from searchcompstat where note is not null;
  begin
  if not CurkeyField%isopen then open CurkeyField; end if;
  Loop 
    fetch CurkeyField into vi_serialno,vs_note;   
     exit when CurkeyField%notfound;
    begin
      vs_sql:='select count(*) as inum from' ||vs_note;
      vs_sql:=Replace(vs_sql,'#','''');
      vs_sql:='update searchcompstat set tablerows=('select count(*) as inum from') where serialno='||to_char(vi_serialno);
      Execute immediate(vs_sql);
      end;
  end Loop;
  if CurkeyField%isopen then close CurkeyField; end if;
  end;
  update searchcompstat set tablerows=(select count(*) as inum from companybase where 1=1 and contains(keyword,'ˮ',1)>0) where serialno=111

3,创建存储过程

create or replace procedure AUTO_STAT is
  vi_serialno integer;
  vs_sql varchar(700);
  vs_note varchar(600);
begin
  declare
  cursor CurkeyField is
  select serialno,note from searchcompstat where note is not null;
  begin
  if not CurkeyField%isopen then open CurkeyField; end if;
  Loop 
    fetch CurkeyField into vi_serialno,vs_note;   
     exit when CurkeyField%notfound;
    begin
      vs_sql:='select count(*) as inum from ' ||vs_note;
      vs_sql:=Replace(vs_sql,'#','''');
      vs_sql:='update searchcompstat set tablerows=('||vs_sql||') where serialno='||to_char(vi_serialno);
      Execute immediate(vs_sql);
      end;
  end Loop;
  if CurkeyField%isopen then close CurkeyField; end if;
  end;
     
  declare
  cursor CurkeyField is
  select serialno,note from searchmanagerstat where note is not null;
  begin
  if not CurkeyField%isopen then open CurkeyField; end if;
  Loop 
    fetch CurkeyField into vi_serialno,vs_note;   
     exit when CurkeyField%notfound;
    begin
      vs_sql:='select count(*) as inum from ' ||vs_note;
      vs_sql:=Replace(vs_sql,'#','''');
      vs_sql:='update searchmanagerstat set tablerows=('||vs_sql||') where serialno='||to_char(vi_serialno);
      Execute immediate(vs_sql);
      end;
  end Loop;
  if CurkeyField%isopen then close CurkeyField; end if;
  end;
     
  declare
  cursor CurkeyField is
  select serialno,note from searchprostat where note is not null;
  begin
  if not CurkeyField%isopen then open CurkeyField; end if;
  Loop 
    fetch CurkeyField into vi_serialno,vs_note;   
     exit when CurkeyField%notfound;
    begin
      vs_sql:='select count(*) as inum from ' ||vs_note;
      vs_sql:=Replace(vs_sql,'#','''');
      vs_sql:='update searchprostat set tablerows=('||vs_sql||') where serialno='||to_char(vi_serialno);
      Execute immediate(vs_sql);
      end;
  end Loop;
  if CurkeyField%isopen then close CurkeyField; end if;
  end;
     
  declare
  cursor CurkeyField is
  select serialno,note from searchprovidestat where note is not null;
  begin
  if not CurkeyField%isopen then open CurkeyField; end if;
  Loop 
    fetch CurkeyField into vi_serialno,vs_note;   
     exit when CurkeyField%notfound;
    begin
      vs_sql:='select count(*) as inum from ' ||vs_note;
      vs_sql:=Replace(vs_sql,'#','''');
      vs_sql:='update searchprovidestat set tablerows=('||vs_sql||') where serialno='||to_char(vi_serialno);
      Execute immediate(vs_sql);
      end;
  end Loop;
  if CurkeyField%isopen then close CurkeyField; end if;
  end;
     
  declare
  cursor CurkeyField is
  select serialno,note from searchreqstat where note is not null;
  begin
  if not CurkeyField%isopen then open CurkeyField; end if;
  Loop 
    fetch CurkeyField into vi_serialno,vs_note;   
     exit when CurkeyField%notfound;
    begin
      vs_sql:='select count(*) as inum from ' ||vs_note;
      vs_sql:=Replace(vs_sql,'#','''');
      vs_sql:='update searchreqstat set tablerows=('||vs_sql||') where serialno='||to_char(vi_serialno);
      Execute immediate(vs_sql);
     
     
    end;
  end Loop;
  if CurkeyField%isopen then close CurkeyField; end if;
  end;
end AUTO_STAT;

2
create or replace procedure HOT_AUTO is
begin
 delete from hot_research_info where classtype=1;
 insert into hot_research_info (serialno,classtype,linenum,keyname,url)
 select s_hot_search.nextval,'1',num,keyword,'javascript:search('''||keyword||''');' from (select * from searchreqstat where keyword not like '%=%' order by num desc) where rownum<=5;
 delete from hot_research_info where classtype=2;
 insert into hot_research_info (serialno,classtype,linenum,keyname,url)
 select s_hot_search.nextval,'2',num,keyword,'javascript:search('''||keyword||''');' from (select * from searchprovidestat where keyword not like '%=%' order by num desc) where rownum<=5;
 delete from hot_research_info where classtype=3;
 insert into hot_research_info (serialno,classtype,linenum,keyname,url)
 select s_hot_search.nextval,'3',num,keyword,'javascript:search('''||keyword||''');' from (select * from searchcompstat where keyword not like '%=%' order by num desc) where rownum<=5;
 delete from hot_research_info where classtype=4;
 insert into hot_research_info (serialno,classtype,linenum,keyname,url)
 select s_hot_search.nextval,'4',num,keyword,'javascript:search('''||keyword||''');' from (select * from searchprostat where keyword not like '%=%' order by num desc) where rownum<=5;
 delete from hot_research_info where classtype=5;
 insert into hot_research_info (serialno,classtype,linenum,keyname,url)
 select s_hot_search.nextval,'5',num,keyword,'javascript:search('''||keyword||''');' from (select * from searchmanagerstat where keyword not like '%=%' order by num desc) where rownum<=5;
end HOT_AUTO;

4,创建触发器

CREATE OR REPLACE TRIGGER TRG_provideinfo BEFORE
INSERT  ON provideinfo
FOR EACH ROW
begin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值