oracle 存储过程

create or replace procedure text(
startTime in varchar2, [color=red] in标记为输入参数[/color]endTime in varchar2,
timeType in number,
spID in number,
newBlackCount out number , [color=red] out标记为输入参数[/color]
blackTotalCount out number,
mdn in varchar2
)
is
strsql varchar2(5000); [color=red] 定义变量[/color]
basicstrsql varchar2(5000);
strsql_1 varchar(5000);
strsql_2 varchar(5000);
strsql_3 varchar(5000);
v_dataCount number;
pattern varchar(10) ;
begin
--初始化参数
strsql_1 :='';
strsql_2 :='';
strsql_3 :='';
newBlackCount := 0 ;
blackTotalCount := 0 ;

if timeType = 0 then
pattern :='yyyy-mm-dd' ;[color=red]定义时间样式[/color]
else
pattern :='yyyy_mm';
end if ;
--开始时间结束时间内新增黑名单数
basicstrsql := 'select count(black.object) blackcount from nm_black_and_object black where 1=1 ' ;

if spID > 0 then
basicstrsql := basicstrsql || ' and black.sp_id ='||spID ;
end if ;
strsql := basicstrsql ;
if startTime is not null then
strsql_1 := ' and to_char(create_date,'''||pattern||''') >=''' ||startTime|| '''' ;
strsql := strsql || strsql_1 ;
end if ;
if endTime is not null then
strsql_2 := ' and to_char(create_date,'''||pattern||''') <=''' ||endTime|| '''' ;
strsql := strsql || strsql_2 ;
end if ;
if spID >0 then
strsql_3 := ' and black.sp_id = '||spID||'' ;
strsql := strsql || strsql_3 ;
end if ;
execute immediate strsql into v_dataCount;
newBlackCount := newBlackCount + v_dataCount ;

strsql := basicstrsql || strsql_2||strsql_3;
execute immediate strsql into v_dataCount;
blackTotalCount := blackTotalCount + v_dataCount ;
end text;

一个小例子 这是我第一次写存储过程,有很多的不足 ,希望高手能多多评点 ,java小生不胜感激
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值