- 浏览: 377285 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
lhbthanks:
楼主写的很多,也很实用,要是再增加一些描述就会更好了。
oracle 用户 从一个表空间 另一个表空间 -
wuhuajun:
private int _connectionMax = 51 ...
resin jboss 最大连接数设置 -
shixiaomu:
自己丁丁丁一下 学了忘忘了再学。。主要是应用场景太少
python -
shixiaomu:
我自己有了方案了java+rabbitmq_server-2. ...
hadoop hive zookeeper 还不够 -
shixiaomu:
看到这个帖子 羞愧极了 ,原来 我 09 年就想学 pytho ...
python
CREATE OR REPLACE PROCEDURE user_learn_stat_p(v_in_user_id IN number) AS
--参数IN表示输入参数,
--OUT表示输入参数,类型可以使用任意Oracle中的合法类型。
--定义变量
v_classroom_id number(10); --课程id
v_user_id number(10); --课程id
vs_msg varchar2(4000); --错误信息变量
dept_no_array_c dbms_sql.Number_Table; --数组完成
ilm_classroom_id dbms_sql.Number_Table; --综合学习课程id
dept_no_array_t dbms_sql.Number_Table; --数组总计
dept_no_array_classroom dbms_sql.Number_Table; --数组classroomid
dept_no_array_classroom_name dbms_sql.Varchar2_Table; --数组classroom名称
v_classroom_count number(10);
v_i number(10);
v_j number(10);
v_k number(10);
v_kk number(10);
v_ret number(10);
--定义游标(简单的说就是一个可以遍历的结果集)
CURSOR cur_1 IS
select C.id,
C.name,
C.type,
EV.start_date,
C.rco_id,
NVL(R.title, '') as rco_title,
'Y' as is_enrolled,
C.location,
C.is_sample,
C.is_browsable,
'Y' as is_published,
DECODE(C.cal_ev_featured, null, 'N', 'Y') as is_featured,
cg.name as content_group_name,
E.cert_period_start_date,
E.cert_period_end_date,
E.initial_certification_days,
E.renewal_certification_days
from classroom C,
cal_events EV,
rco R,
enrollment E,
privilege_ref P,
content_group cg
where P.user_id = v_in_user_id
and P.target_id = E.classroom_id
and E.user_id = v_in_user_id
and E.classroom_id = C.id
and E.is_deleted = 'N'
and C.cal_event_id = EV.id
and C.is_published = 'Y'
and C.is_hidden = 'N'
and (EV.end_date > sysdate OR EV.end_date IS NULL OR
EV.repeat_until > sysdate)
and C.content_group_id = cg.id
and C.rco_id = R.id(+)
and C.id not in(
SELECT /* IlmEnrolledView */
--c.name as cname,
c.id as cid
FROM GROUP_ENROLLMENT GE,
CLASSROOM_GROUP CG,
classroom_group_xref x,
classroom c
WHERE GE.CLASSROOM_GROUP_ID = CG.ID
and x.class_id = c.id
and cg.id = x.group_id
AND CG.IS_PUBLISHED = 'Y'
AND GE.USER_ID = v_in_user_id
AND GE.IS_DELETED = 'N'
AND GE.SITE_ID = CG.SITE_ID
AND CG.TYPE = 'I'
);
CURSOR cur_2 IS
SELECT /* IlmEnrolledView */
c.name as cname, c.id as cid
FROM GROUP_ENROLLMENT GE,
CLASSROOM_GROUP CG,
classroom_group_xref x,
classroom c
WHERE GE.CLASSROOM_GROUP_ID = CG.ID
and x.class_id = c.id
and cg.id = x.group_id
AND CG.IS_PUBLISHED = 'Y'
AND GE.USER_ID = v_in_user_id
AND GE.IS_DELETED = 'N'
AND GE.SITE_ID = CG.SITE_ID
AND CG.TYPE = 'I';
BEGIN
select count(*)
into v_classroom_count
from classroom C,
cal_events EV,
rco R,
enrollment E,
privilege_ref P,
content_group cg
where P.user_id = v_in_user_id
and P.target_id = E.classroom_id
and E.user_id = v_in_user_id
and E.classroom_id = C.id
and E.is_deleted = 'N'
and C.cal_event_id = EV.id
and C.is_published = 'Y'
and C.is_hidden = 'N'
and (EV.end_date > sysdate OR EV.end_date IS NULL OR
EV.repeat_until > sysdate)
and C.content_group_id = cg.id
and C.rco_id = R.id(+)
and C.id not in(
SELECT /* IlmEnrolledView */
--c.name as cname,
c.id as cid
FROM GROUP_ENROLLMENT GE,
CLASSROOM_GROUP CG,
classroom_group_xref x,
classroom c
WHERE GE.CLASSROOM_GROUP_ID = CG.ID
and x.class_id = c.id
and cg.id = x.group_id
AND CG.IS_PUBLISHED = 'Y'
AND GE.USER_ID = v_in_user_id
AND GE.IS_DELETED = 'N'
AND GE.SITE_ID = CG.SITE_ID
AND CG.TYPE = 'I'
);
--用输入参数给变量赋初值,用到了Oralce的SUBSTR TO_CHAR ADD_MONTHS TO_DATE 等很常用的函数。
v_user_id := v_in_user_id;
--然后用内置的DBMS_OUTPUT对象的put_line方法打印出影响的记录行数,其中用到一个系统变量SQL%rowcount
--DBMS_OUTPUT.put_line('del上月记录='||SQL%rowcount||'条');
--遍历游标处理后更新到表。遍历游标有几种方法,用for语句是其中比较直观的一种。
v_k := 0;
FOR rec2 IN cur_2 LOOP
v_k := v_k + 1;
ilm_classroom_id(v_k) := rec2.cid;
dbms_output.put_line('综合学习'||ilm_classroom_id(v_k));
END LOOP;
v_i := 0;
FOR rec IN cur_1 LOOP
v_i := v_i + 1;
v_classroom_id := rec.id;
dept_no_array_classroom(v_i) := rec.id;
select mm.name
into dept_no_array_classroom_name(v_i)
from classroom mm
where mm.id = v_classroom_id;
SELECT /* UserStatusView */
completed, total
into dept_no_array_c(v_i), dept_no_array_t(v_i)
FROM (SELECT SUM(DECODE(nvl(P.STATUS, 'N'), 'N', 1, 0)) AS NOT_ATTEMPTED,
SUM(DECODE(P.STATUS, 'C', 1, 0)) AS COMPLETED,
SUM(DECODE(P.STATUS, 'P', 1, 0)) AS PASSED,
SUM(DECODE(P.STATUS, 'I', 1, 0)) AS INCOMPLETE,
SUM(DECODE(P.STATUS, 'F', 1, 0)) AS FAILED,
COUNT(P.child_id) AS TOTAL
FROM (select x.child_id, P.status
from tree_xref x,
performance p,
rco,
classroom c,
enrollment E
where c.id = v_classroom_id
and x.parent_id = c.rco_id
and x.child_id = rco.id
and p.rco_id(+) = rco.source_rco_id
and p.user_id(+) = v_user_id
and rco.is_published = 'Y'
and E.user_id(+) = v_user_id
and E.classroom_id(+) = C.id
and E.cert_period_start_date is null
UNION
select x.child_id, P.status
from tree_xref x,
certification_performance p,
rco,
classroom c,
enrollment E
where c.id = v_classroom_id
and x.parent_id = c.rco_id
and x.child_id = rco.id
and p.rco_id(+) = rco.source_rco_id
and p.user_id(+) = v_in_user_id
and p.classroom_id(+) = v_classroom_id
and p.end_date(+) is null
and rco.is_published = 'Y'
and E.user_id = v_user_id
and E.classroom_id = C.id
and E.cert_period_start_date is not null) P);
END LOOP;
dbms_output.put_line('课程总计');
dbms_output.put_line(v_classroom_count);
v_ret := 0;
FOR v_j in 1 .. v_classroom_count loop
if dept_no_array_t(v_j) = 0 or dept_no_array_c(v_j) = 0 or
dept_no_array_c(v_j) / dept_no_array_t(v_j) < 1 then
v_ret := v_ret + 1;
end if;
dbms_output.put_line('!!!');
dbms_output.put_line(v_j);
dbms_output.put_line(dept_no_array_classroom(v_j));
dbms_output.put_line(dept_no_array_classroom_name(v_j));
dbms_output.put_line('完成');
dbms_output.put_line(dept_no_array_c(v_j));
dbms_output.put_line('总计');
dbms_output.put_line(dept_no_array_t(v_j));
dbms_output.put_line('百分比');
dbms_output.put_line(dept_no_array_c(v_j) / dept_no_array_t(v_j));
dbms_output.put_line('&&&');
end loop;
dbms_output.put_line('未完成课程');
dbms_output.put_line(v_ret);
--错误处理部分。OTHERS表示除了声明外的任意错误。SQLERRM是系统内置变量保存了当前错误的详细信息。
EXCEPTION
WHEN OTHERS THEN
vs_msg := 'ERROR IN user_learn_stat_p():' || SUBSTR(SQLERRM, 1, 500);
ROLLBACK;
--把当前错误记录进日志表。
INSERT INTO LOG_INFO
(proc_name, error_info, op_date)
VALUES
('user_learn_stat_p', vs_msg, SYSDATE);
COMMIT;
RETURN;
END;
--参数IN表示输入参数,
--OUT表示输入参数,类型可以使用任意Oracle中的合法类型。
--定义变量
v_classroom_id number(10); --课程id
v_user_id number(10); --课程id
vs_msg varchar2(4000); --错误信息变量
dept_no_array_c dbms_sql.Number_Table; --数组完成
ilm_classroom_id dbms_sql.Number_Table; --综合学习课程id
dept_no_array_t dbms_sql.Number_Table; --数组总计
dept_no_array_classroom dbms_sql.Number_Table; --数组classroomid
dept_no_array_classroom_name dbms_sql.Varchar2_Table; --数组classroom名称
v_classroom_count number(10);
v_i number(10);
v_j number(10);
v_k number(10);
v_kk number(10);
v_ret number(10);
--定义游标(简单的说就是一个可以遍历的结果集)
CURSOR cur_1 IS
select C.id,
C.name,
C.type,
EV.start_date,
C.rco_id,
NVL(R.title, '') as rco_title,
'Y' as is_enrolled,
C.location,
C.is_sample,
C.is_browsable,
'Y' as is_published,
DECODE(C.cal_ev_featured, null, 'N', 'Y') as is_featured,
cg.name as content_group_name,
E.cert_period_start_date,
E.cert_period_end_date,
E.initial_certification_days,
E.renewal_certification_days
from classroom C,
cal_events EV,
rco R,
enrollment E,
privilege_ref P,
content_group cg
where P.user_id = v_in_user_id
and P.target_id = E.classroom_id
and E.user_id = v_in_user_id
and E.classroom_id = C.id
and E.is_deleted = 'N'
and C.cal_event_id = EV.id
and C.is_published = 'Y'
and C.is_hidden = 'N'
and (EV.end_date > sysdate OR EV.end_date IS NULL OR
EV.repeat_until > sysdate)
and C.content_group_id = cg.id
and C.rco_id = R.id(+)
and C.id not in(
SELECT /* IlmEnrolledView */
--c.name as cname,
c.id as cid
FROM GROUP_ENROLLMENT GE,
CLASSROOM_GROUP CG,
classroom_group_xref x,
classroom c
WHERE GE.CLASSROOM_GROUP_ID = CG.ID
and x.class_id = c.id
and cg.id = x.group_id
AND CG.IS_PUBLISHED = 'Y'
AND GE.USER_ID = v_in_user_id
AND GE.IS_DELETED = 'N'
AND GE.SITE_ID = CG.SITE_ID
AND CG.TYPE = 'I'
);
CURSOR cur_2 IS
SELECT /* IlmEnrolledView */
c.name as cname, c.id as cid
FROM GROUP_ENROLLMENT GE,
CLASSROOM_GROUP CG,
classroom_group_xref x,
classroom c
WHERE GE.CLASSROOM_GROUP_ID = CG.ID
and x.class_id = c.id
and cg.id = x.group_id
AND CG.IS_PUBLISHED = 'Y'
AND GE.USER_ID = v_in_user_id
AND GE.IS_DELETED = 'N'
AND GE.SITE_ID = CG.SITE_ID
AND CG.TYPE = 'I';
BEGIN
select count(*)
into v_classroom_count
from classroom C,
cal_events EV,
rco R,
enrollment E,
privilege_ref P,
content_group cg
where P.user_id = v_in_user_id
and P.target_id = E.classroom_id
and E.user_id = v_in_user_id
and E.classroom_id = C.id
and E.is_deleted = 'N'
and C.cal_event_id = EV.id
and C.is_published = 'Y'
and C.is_hidden = 'N'
and (EV.end_date > sysdate OR EV.end_date IS NULL OR
EV.repeat_until > sysdate)
and C.content_group_id = cg.id
and C.rco_id = R.id(+)
and C.id not in(
SELECT /* IlmEnrolledView */
--c.name as cname,
c.id as cid
FROM GROUP_ENROLLMENT GE,
CLASSROOM_GROUP CG,
classroom_group_xref x,
classroom c
WHERE GE.CLASSROOM_GROUP_ID = CG.ID
and x.class_id = c.id
and cg.id = x.group_id
AND CG.IS_PUBLISHED = 'Y'
AND GE.USER_ID = v_in_user_id
AND GE.IS_DELETED = 'N'
AND GE.SITE_ID = CG.SITE_ID
AND CG.TYPE = 'I'
);
--用输入参数给变量赋初值,用到了Oralce的SUBSTR TO_CHAR ADD_MONTHS TO_DATE 等很常用的函数。
v_user_id := v_in_user_id;
--然后用内置的DBMS_OUTPUT对象的put_line方法打印出影响的记录行数,其中用到一个系统变量SQL%rowcount
--DBMS_OUTPUT.put_line('del上月记录='||SQL%rowcount||'条');
--遍历游标处理后更新到表。遍历游标有几种方法,用for语句是其中比较直观的一种。
v_k := 0;
FOR rec2 IN cur_2 LOOP
v_k := v_k + 1;
ilm_classroom_id(v_k) := rec2.cid;
dbms_output.put_line('综合学习'||ilm_classroom_id(v_k));
END LOOP;
v_i := 0;
FOR rec IN cur_1 LOOP
v_i := v_i + 1;
v_classroom_id := rec.id;
dept_no_array_classroom(v_i) := rec.id;
select mm.name
into dept_no_array_classroom_name(v_i)
from classroom mm
where mm.id = v_classroom_id;
SELECT /* UserStatusView */
completed, total
into dept_no_array_c(v_i), dept_no_array_t(v_i)
FROM (SELECT SUM(DECODE(nvl(P.STATUS, 'N'), 'N', 1, 0)) AS NOT_ATTEMPTED,
SUM(DECODE(P.STATUS, 'C', 1, 0)) AS COMPLETED,
SUM(DECODE(P.STATUS, 'P', 1, 0)) AS PASSED,
SUM(DECODE(P.STATUS, 'I', 1, 0)) AS INCOMPLETE,
SUM(DECODE(P.STATUS, 'F', 1, 0)) AS FAILED,
COUNT(P.child_id) AS TOTAL
FROM (select x.child_id, P.status
from tree_xref x,
performance p,
rco,
classroom c,
enrollment E
where c.id = v_classroom_id
and x.parent_id = c.rco_id
and x.child_id = rco.id
and p.rco_id(+) = rco.source_rco_id
and p.user_id(+) = v_user_id
and rco.is_published = 'Y'
and E.user_id(+) = v_user_id
and E.classroom_id(+) = C.id
and E.cert_period_start_date is null
UNION
select x.child_id, P.status
from tree_xref x,
certification_performance p,
rco,
classroom c,
enrollment E
where c.id = v_classroom_id
and x.parent_id = c.rco_id
and x.child_id = rco.id
and p.rco_id(+) = rco.source_rco_id
and p.user_id(+) = v_in_user_id
and p.classroom_id(+) = v_classroom_id
and p.end_date(+) is null
and rco.is_published = 'Y'
and E.user_id = v_user_id
and E.classroom_id = C.id
and E.cert_period_start_date is not null) P);
END LOOP;
dbms_output.put_line('课程总计');
dbms_output.put_line(v_classroom_count);
v_ret := 0;
FOR v_j in 1 .. v_classroom_count loop
if dept_no_array_t(v_j) = 0 or dept_no_array_c(v_j) = 0 or
dept_no_array_c(v_j) / dept_no_array_t(v_j) < 1 then
v_ret := v_ret + 1;
end if;
dbms_output.put_line('!!!');
dbms_output.put_line(v_j);
dbms_output.put_line(dept_no_array_classroom(v_j));
dbms_output.put_line(dept_no_array_classroom_name(v_j));
dbms_output.put_line('完成');
dbms_output.put_line(dept_no_array_c(v_j));
dbms_output.put_line('总计');
dbms_output.put_line(dept_no_array_t(v_j));
dbms_output.put_line('百分比');
dbms_output.put_line(dept_no_array_c(v_j) / dept_no_array_t(v_j));
dbms_output.put_line('&&&');
end loop;
dbms_output.put_line('未完成课程');
dbms_output.put_line(v_ret);
--错误处理部分。OTHERS表示除了声明外的任意错误。SQLERRM是系统内置变量保存了当前错误的详细信息。
EXCEPTION
WHEN OTHERS THEN
vs_msg := 'ERROR IN user_learn_stat_p():' || SUBSTR(SQLERRM, 1, 500);
ROLLBACK;
--把当前错误记录进日志表。
INSERT INTO LOG_INFO
(proc_name, error_info, op_date)
VALUES
('user_learn_stat_p', vs_msg, SYSDATE);
COMMIT;
RETURN;
END;
发表评论
-
数据库的原理-侧重索引
2014-06-25 16:32 783统计信息和过滤因子 分布统计信息 (信息分布不均衡.存在重复数 ... -
redis并发统计
2012-11-20 18:24 1226统计并发. 是从1970年1月1日(UTC/GMT的午夜)开始 ... -
linux Page cache和buffer cache 正解
2012-11-13 16:17 1024Page cache和buffer cache一直以来是两个比 ... -
Redis被bgsave和bgrewriteaof阻塞的解决方法(转)
2012-08-02 11:26 766Redis 是一个性能非常高效的内存 Key-Value 存储 ... -
热点账户得问题
2010-08-10 13:44 1413热点账户得问题 -
执行查询cpu100%
2010-04-23 18:31 894联表是笛卡尔积还是左关联或者有关联? 不要看你查出来多少 ... -
oracle dbLink
2010-02-05 11:35 1007俩台不同的数据库服务器,从一台数据库服务器的一个用户读取另一台 ... -
oracle job 定时器 脚本
2009-09-02 11:55 1826declare JOB_ILEARN_ONLINE numb ... -
oracle 动态sql
2009-06-25 13:47 975用decode取代where条件的动态sql select ... -
oracle trigger 表名 列名
2009-06-04 11:39 1018select 'create or replace trigg ... -
oracle 数据库 触发器 trigger 语法
2009-06-04 09:23 6080关键字: oracle 数据库 触发器 trigger 语法 ... -
标准 oracle 存储过程 模板
2009-04-23 11:03 1350--创建存储过程 CREATE OR REPLACE PROC ... -
hql 日期 减法
2009-02-17 10:26 1270错误:select t from user t where t ... -
linux 安装 oracle 常见问题
2009-02-15 13:30 12611. 安装前的hosts文件 l cat /etc/ ... -
oracle 用户 从一个表空间 另一个表空间
2009-02-03 23:37 7662--------------重要--------------- ... -
oracle密码文件
2009-02-03 23:31 936很多时候需要对ORACLE密码文件进行重建,ORACLE对密码 ... -
配置Oracle9i的归档模式
2009-02-01 14:35 2733配置Oracle9i的归档模式 ... -
oracle的冷热备份大全
2009-02-01 13:38 1176Oracle备份与恢复案例 By Piner 一. 理 ... -
linux oracle 的定时恢复和备份
2009-01-20 12:37 27301.exp导出 #!/bin/sh ORACLE_HO ...
相关推荐
oracle proc 接口编程。pdf文档。
oracle,proc*c程序设计,很实用。 一个是目录,一个是文件。
oracle 11g下PROC C++编程源代码,有20多个样例供参考!
提供Oracle ProC程序的开发,详尽的介绍Proc的开发过程
本系列教程是配合Oracle教程而编写的,具有较强的系统性,内容包括Oracle 7所支持的最新应用开发工具和相关产品。是数据库系统开发人员和最终用户的参考资料。
Oracle ProC 编程入门,学习ORACLE proc 编程的金典资料
一个完整的proc程序,有详细的操作过程。有助于初学者的学习和使用。
Oracle ProC 编程入门 PROC是ORACLE数据库提供的编程接口之一,其应用十分的广泛。
Pro*C/C++从此版本起具备了执行标准动态SQL 语句的接口,增强了Oracle 动态 语句接口的功能。标准动态SQL 语句接口支持所有Oracle 的数据类型,包括 Objects,结构数组,游标变量和LOBS。 ※ DML 语句开始支持返回
同步每个人的时长的oracle proc,游标的使用,函数的使用同步每个人的时长的oracle proc,游标的使用,函数的使用同步每个人的时长的oracle proc,游标的使用,函数的使用
Oracle ProC 编程入门.pdf
ORACLE PROC_*C编程点滴.pdf
Oracle Proc培训资料整理,适合与初学者了解和使用proc访问oracle数据库进行快速编程。
Oracle ProC 编程 视频 Oracle ProC 编程 视频
oracle proc error & example silent install
Oracle PorC 详细讲解,附带源码
Proc开发文档
Unix下Oracle数据库开发必备资料
ORACLE数据库PROC编程经验介绍.PROC是ORACLE数据库提供的编程接口之一,其应用十分的广泛,本文通过一个具体的例子,介绍PROC编程的一些经验及应注意的地方
oracle+proc+c的学习,个人看了感觉非常好,学习中。