oracle中函数和存储过程小例子

create or replace function f_login_pwd_check
(
    i_in_operateid        in     number,  --操作员账号
    i_in_operatortype     in     number,  --操作员类型(1.系统管理员 2.铃音制作商 3.集团管理员)
    i_in_loginPwdTimeout  in     number   --配置项中密码有效期                                         
) return integer                          --返回值 0过期 1没过期
is
    i_l_count   integer;
    i_l_lastpwdtime integer;
    dt_l_createtime date;
begin
    select count(1) into i_l_count
      from t_operatorinfo
     where operateid = i_in_operateid and operatortype = i_in_operatortype;
    if (i_l_count = 0) then
        insert into t_operatorinfo
                    (
                    operateinfoid,
                    operateid,
                    operatortype,
                    status,
                    lastlogined,
                    failnum,
                    lastpwdtime
                    )
             values
                    (
                    s_operatorinfoid.nextval,
                    i_in_operateid,
                    i_in_operatortype,
                    1,
                    sysdate,
                    0,
                    dt_l_createtime
                    );
        commit;
    end if;


    select (sysdate - lastpwdtime) * 24 * 60 * 60 into i_l_lastpwdtime
      from t_operatorinfo
     where operateid = i_in_operateid and operatortype = i_in_operatortype;


    if (i_l_lastpwdtime < i_in_loginPwdTimeout*24*60*60) then
        return 1;
    end if;
    return 0;
exception
    when others then
      --记录异常信息
    rollback;
    return -1;
end f_login_pwd_check;




--创建存储过程--
create or replace procedure p_statsinfo
as


   i_l_return            integer;
   i_l_result            integer;
   dt_l_statsdate        date;
begin
   dt_l_statsdate := trunc(sysdate);
   i_l_result := f_di_statsinfo(dt_in_statsdate => dt_l_statsdate,i_out_result =>i_l_result );


end p_statsinfo;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值