oracle 存储过程
来源:互联网 发布:数值型数据 编辑:程序博客网 时间:2024/05/14 05:00
create or replace procedure count_retire is
nowYear varchar2(20);myCusor SYS_REFCURSOR;
--totals varchar2(20);
begin
select to_char(sysdate,'yyyy') into nowYear from dual;
delete TJ_RETIREMAN a where a.data_year= nowYear;
commit;
for myCusor in (
select RAWTOHEX(SYS_GUID()) ID ,m.rpr_type,
MAX(DECODE(m.sex, '1', m.total, 0)) MALE,
MAX(DECODE(m.sex, '2', m.total, 0)) FEMALE,
MAX(DECODE(m.sex, '1', m.total, 0))+ MAX(DECODE(m.sex, '2', m.total, 0)) total,
m.commname,m.commno
from (select
RAWTOHEX(SYS_GUID()) ID,
count(*) as total,
t.sex,
t.commno,
c.commname,
t.rpr_type
from SQ_GE_PERSONINFO t,
SQ_GE_COMM C
where t.commno = c.commno
and (t.is_del <> '-1' or t.is_del is null)
and t.birth_date is not null
-- and (EXTRACT(YEAR FROM sysdate) - EXTRACT(YEAR FROM t.birth_date) + 1 >= 50 and
-- t.sex = '2')
-- or (EXTRACT(YEAR FROM sysdate) - EXTRACT(YEAR FROM t.birth_date) + 1 >= 60 and
-- t.sex = '1')
group by t.commno, c.commname, t.rpr_type, t.sex
)m
group by m.rpr_type,m.commname,m.commno )
--插入数据
loop
insert into TJ_RETIREMAN
(
id,
commno,
rpr_type,
total,
DATA_YEAR,
commname,
male_num,
female_num
)
values
(
myCusor.id,
myCusor.commno,
myCusor.rpr_type,
myCusor.total,
nowYear,
myCusor.commname,
myCusor.male,
myCusor.female
);
end loop;
commit;
end count_retire;
0 0
- Oracle:存储过程,存储函数
- Oracle-存储过程 存储函数
- Oracle存储过程、存储函数
- oracle 存储函数,存储过程
- Oracle存储过程
- 调试oracle存储过程。
- ORACLE 存储过程实战
- Oracle 存储过程
- oracle存储过程使用
- Oracle 创建存储过程
- 调试oracle存储过程
- oracle java存储过程
- 创建Oracle存储过程
- 加密oracle存储过程
- oracle存储过程分页
- oracle存储过程笔记
- ORACLE存储过程--注意事项
- oracle procedure 存储过程
- 大话进程与线程
- ThreadPoolExecutor机制
- Activity生命周期详解(一)单个activity
- C++实验5:数组选择
- 纪念品分组
- oracle 存储过程
- 取石子
- 西电捷通TISec远程访问技术应用实例
- 微信支付接入那些坑1-----[__NSArrayM enqueue:]: unrecognized selector sent to instance
- [置顶] Android开源库V
- spring cloud-hystrix
- 解决javascript中的浮点数计算不精确问题
- C++作业五
- dpdk中文-使用openwrt-SDK编译DPDK