1、declare
--人物
cursor profile_cursor is select base.profileid from profile_baseinfo base where base.updatetime > sysdate - 5/1440;
--圈子
cursor group_cursor is select bbase.groupid from group_baseinfo bbase where bbase.updatetime > sysdate - 5/1440;
--博客
cursor article_cursor is select art.id from profile_article art where art.status =1 and art.updatetime >sysdate - 5/1440;
--论坛主题
cursor topic_cursor is select distinct posts.topic_id from shequsystem.jforum_posts posts where posts.post_time > sysdate - 5/1440 or posts.post_edit_time > sysdate - 5/1440;
text blob;
maxid number(12);
begin
for profile in profile_cursor loop
dbms_output.put_line(profile.profileid);
end loop;
for g in group_cursor loop
dbms_output.put_line('g');
end loop;
for article in article_cursor loop
dbms_output.put_line('a');
end loop;
for topic in topic_cursor loop
select topic_id into shequsystem.jforum_search_data from shequsystem.jforum_topics where topic_id = topic.topic_id;
select * from jforum_topics t,jforum_forums f,jforum_users u
where t.forum_id = f.forum_id and t.user_id = u.user_id
end loop;
end;
2、declare
TYPE PROFILE_CURSOR IS REF CURSOR;
V_PROFILE_CURSOR PROFILE_CURSOR;--声明游标
v_profile_id number(12);--人物id
v_profile_sex number(1);--性别
v_img_path varchar2(400);--图片路径
v_dic_path varchar2(100);--图片服务器路径
v_random number(1);--0~4随机数
BEGIN
v_dic_path := 'upload/profimg/defalutPic/';
OPEN V_PROFILE_CURSOR FOR
--取出人物图像路径为空的
select base.profileid,base.sex,base.photo from profile_baseinfo base where base.photo is null;
LOOP
SELECT round(dbms_random.value(0,4)) into v_random FROM dual;
FETCH V_PROFILE_CURSOR INTO v_profile_id,v_profile_sex,v_img_path;
EXIT WHEN V_PROFILE_CURSOR%NOTFOUND;
--男
IF v_profile_sex = 1 THEN
v_img_path := v_dic_path || 'male/profileDefault_'||v_random;
END IF;
IF v_profile_sex = 2 THEN
--女
v_img_path := v_dic_path || 'female/profileDefault_'||v_random;
END IF;
update profile_baseinfo set photo = v_img_path where profileId = v_profile_id;
--dbms_output.put_line();
END LOOP;
commit;
CLOSE V_PROFILE_CURSOR;
END;