分区语句整理 5

begin

    /**

     * @description exc_error1 will be raised if iv_username is null and the input string have 4 split symbol

     * @description get the users' number which is from input parameter

     */

    if (iv_username is null) then

    raise exc_error1;

    elsif instr(iv_username,',',1,4)>0 then

    raise exc_error1;

    end if;

    vi_users_num:=((length(iv_username)-length(replace(iv_username,',')))/length(','))+1;

    /**

     * @description split the input parameter, get the exactly user name and check whether them are exist in the system,

                    raise the exc_error3 if some one is not exist.

     */

    vv_capi_usernam := upper(iv_username);

    if vi_users_num = 1 then

        vv_user1 := vv_capi_usernam;

        vv_user2 := null;

        vv_user3 := null;

        vv_user4 := null;

        execute immediate 'select count(*) from all_users t where t.username='''||vv_user1||'''' into vi_users_flag ;

        if vi_users_flag <> 1 then

            raise exc_error3;

        end if;

    elsif vi_users_num = 2 then

        vv_user1 := substr(vv_capi_usernam,1,instr(vv_capi_usernam,',',1,1)-1);

        vv_user2 := substr(vv_capi_usernam,instr(vv_capi_usernam,',',1,1)+1,(length(vv_capi_usernam)-instr(vv_capi_usernam,',',1,1)));

        vv_user3 := null;

        vv_user4 := null;

        execute immediate 'select count(*) from all_users t where t.username in ('''||vv_user1||''','''||vv_user2||''')'

                          into vi_users_flag ;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值