一个Oracle存储过程
来源:互联网 发布:店淘软件 编辑:程序博客网 时间:2024/05/16 06:18
create or replace procedure sp_ProfitSharing(v_date date,v_oparatorId NUMBER) as
--定义变量
v_revenue NUMBER;
v_toll NUMBER;
v_settlementFactor NUMBER(5);
v_recordGenTime DATE:=sysdate;
v_recordStatus NUMBER(2);
v_count NUMBER;
begin
--判断当日期是否已结算,如果是将status变为1,即为废弃状态
select count(*) into v_count from dd_profit_sharing d
where d.statistic_date = v_date;
if v_count>0 then
update dd_profit_sharing d set d.record_status=1 where d.statistic_date = v_date;
end if;
Declare
Cursor tollCursor Is
select d.toll,d.station_code,d.statistic_date from dd_toll_tracffic_daily d
where d.statistic_date = v_date and d.record_status=0;
varT tollCursor%rowType;
Cursor factorCursor Is
select t.settlement_object_code,t.settlement_factor from sd_settlement_factor t;
varE factorCursor%rowType;
Begin
if tollCursor%isopen = false then
open tollCursor;
dbms_output.put_line('Opening...');
end if;
loop
fetch tollCursor into varT;
exit when tollCursor%notfound;
Begin
if factorCursor%isopen = false then
open factorCursor;
dbms_output.put_line('Opening...');
end if;
loop
fetch factorCursor into varE;
exit when factorCursor%notfound;
v_revenue:=varE.settlement_factor * varT.toll * 0.0001;
v_toll:=varT.toll;
v_settlementFactor:=varE.settlement_factor;
v_recordStatus:=0;
insert into dd_profit_sharing values(dd_profit_sharing_seq.nextval,v_date,
varT.station_code,varE.settlement_object_code,v_revenue,v_toll,v_settlementFactor,v_oparatorId,
v_recordGenTime,v_recordStatus);
end loop;
if factorCursor%isopen then
Close factorCursor;
dbms_output.put_line('Closing...');
end if;
End;
end loop;
if tollCursor%isopen then
Close tollCursor;
dbms_output.put_line('Closing...');
end if;
End;
end;
- 一个Oracle存储过程
- 一个简单oracle存储过程
- oracle存储过程一个陷阱
- 一个简单的oracle存储过程
- 一个简单的oracle存储过程
- oracle的一个简单的存储过程
- Oracle Job 定时执行一个存储过程
- oracle 存储过程 是一个事务
- oracle定时执行一个存储过程
- 一个简单的oracle存储过程
- oracle 创建一个job运行存储过程
- 通过一个实际的例子学习Oracle存储过程
- 通过一个实际的例子学习Oracle存储过程
- 通过一个实际的例子学习Oracle存储过程
- 通过一个实际的例子学习Oracle存储过程
- 一个 Oracle 存储过程编写的入门级例子
- 一个Oracle存储过程编译死锁的奇怪现象
- 通过一个实际的例子学习Oracle存储过程
- 测试大数据(快速排序)100万条数据
- 【数学】关于素数的检验
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
- ABBYY FineReader 12激活过程详解
- 虚函数问题
- 一个Oracle存储过程
- nyoj-2 括号配对【栈】
- Android Adapter接口
- Java main方法
- ThinkPHP项目iis部署一些问题
- mysql字段取值参考
- UISearchBar子类实例化 快速创建搜索框
- I/O复用中,epoll 和select 的区别,以及epoll和select的实例
- 几个著名Java开源缓存框架介绍(OSCache,JSC)