项目实战应用——根据父资源库分类属性修改子资源库分类的属性
2014-10-30 11:31
369 查看
整体要求:
1、先查询出父资源库分类的所有资源库属性元数据
2、然后再查询出父资源库分类的所有子资源库分类
3、最后将子分类中没有而父分类中有的资源库属性元数据插入到子资源库分类中
初学Oracle,还请大虾们多多指教!
1、先查询出父资源库分类的所有资源库属性元数据
2、然后再查询出父资源库分类的所有子资源库分类
3、最后将子分类中没有而父分类中有的资源库属性元数据插入到子资源库分类中
declare --定义可以利用的资源库分类属性元数据值主键id var_com_meta_value_id communitymetavalue.com_meta_value_id%type;--(最小值:17,最大值:521) --定义临时最大place var_max_place number; --定义查询数量,用于判断是否存在 var_exists_count number; --定义临时的资源库分类属性元数据field的id var_com_meta_field_id communitymetavalue.community_mete_field_id%type; --定义临时的资源库分类属性的值 var_com_meta_field_value communitymetavalue.text_value%type; --定义临时community_id var_community_id community.community_id%type; var_number number; --定义游标 --查询资源库分类的所有属性 cursor com_meta_cursor is select comval.* from communitymetavalue comval join communitymetadesc comdes on comdes.community_mete_field_id = comval.community_mete_field_id where comval.object_id = 'sjk' and comval.object_type = 'community'; com_all_meta_record com_meta_cursor%rowtype; --查询资源库分类的直接子资源库分类 cursor child_community_cursor is select com.community_id from community com join community2community c2c on c2c.parent_community_id = 'sjk' and c2c.community_id = com.community_id where com.withdrawn = 'N'; type temp_table_type is table of com_all_meta_record%type index by binary_integer; temp_table temp_table_type; begin var_number:=1; --初始化var_com_meta_value_id var_com_meta_value_id:='17'; open com_meta_cursor; loop fetch com_meta_cursor into com_all_meta_record; exit when com_meta_cursor%notfound; temp_table(var_number):=com_all_meta_record; var_number:=var_number+1; end loop; close com_meta_cursor; --循环资源库子分类 open child_community_cursor; loop fetch child_community_cursor into var_community_id; --查询数据库分类最大的place select max(comval.place) into var_max_place from communitymetavalue comval where comval.object_id = var_community_id and comval.object_type = 'community'; for i in 1..temp_table.count loop --var_max_place加1,var_com_meta_value_id加1 var_max_place:=var_max_place+1; var_com_meta_value_id:=to_char(to_number(var_com_meta_value_id)+1); --查询该属性是否存在 select count(1) into var_exists_count from communitymetavalue where communitymetavalue.object_id = var_community_id and communitymetavalue.object_type = 'community' and communitymetavalue.community_mete_field_id = var_com_meta_field_id; if var_exists_count <= 0 then --给数据库分类增加属性 dbms_output.put_line('insert into communitymetavalue (com_meta_value_id, community_id, community_mete_field_id, text_value, text_lang, place, is_set, community_type_id, object_id, object_type) values('''||var_com_meta_value_id||''', '''||var_community_id||''', '''||temp_table(i).community_mete_field_id||''', '''||temp_table(i).text_value||''', '''', '||var_max_place||', ''0'', ''rwsk'', '''||var_community_id||''', ''community'');'); end if; end loop; --当游标找不到数据时,退出 exit when child_community_cursor%notfound; end loop; --关闭游标 close child_community_cursor; end;
初学Oracle,还请大虾们多多指教!
相关文章推荐
- android 一个应用去获取另一个应用assets下面的资源通过框架代码桥梁------项目实战成功案例
- 实战3--项目开始--准备:::资源分类, 日志系统, 写BaseDao
- 【SSH项目实战】国税协同平台-3.资源文件分类&log4j&抽取BaseAction
- 【SSH项目实战】国税协同平台-3.资源文件分类&log4j&抽取BaseAction
- 异构计算-2-根据程序的属性分类
- 无限级分类的实战应用--查找子孙树,与查找家谱树
- MyEclipse应用------项目在工作区分类
- 应用资源系列之属性[Attribute]资源
- 项目经理案头手册学习系列【9、10】——资源强制进度计划、应用PERT编制进度计划
- 反射应用之一:根据控件名、属性名进行取值和赋值
- 文件不是项目的一部分或其“生成操作”属性未设置为“资源”
- MyEclipse修改页面模板(JSP和HTML等) 分类: WEB项目应用 2010-01-31 00:03 698人阅读 评论(1) 收藏
- Spring 3.x企业应用开发实战(4)----资源加载
- Android <Android应用开发实战> 资源类型<二>
- 分类:决策树—— 对连续属性进行“二元转化”划分,根据增益量公式求最佳划分点
- 关于Scrum在项目实战中的应用
- 根据分类属性来获取目录
- 让web程序也能自动安装 分类: WEB项目应用 2009-12-01 17:02 488人阅读 评论(0) 收藏
- 微软WCF应用高级进阶(分布式+异步调用+安全+通信模式)配销售管理平台项目实战
- 项目管理之敏捷开发-Scrum应用实战(二)