我有个存储过程的问题,不知道怎么处理,可以帮我吗?
create or replace procedure timelong_new(p_tele in number,by_call in number,o_flag out number,already_moneys out number) is
restrict number; --定义是否限制费用
o_moneys number; --定义电话不同类型的最大消费额
o_count number;
--1,私户,2,公户,3,黑户,4,呼转,6,红户
begin
--从phone_sihu表和phone_xlt表中查找符合主叫p_tele的记录,输出电话类型o_flag
select flag into o_flag from phone_sihu where tele=p_tele;
case o_flag
when 1 then o_moneys:=3000;
when 2 then o_moneys:=27900;
when 3 then o_moneys:=900;
when 6 then o_moneys:=900;already_moneys:=360; --红户直接输出时长:360秒
else o_moneys:=27900; --没有符合主叫的记录则输出类型为:呼转
end case;
exception
when NO_DATA_FOUND THEN
o_flag:=4; --以上两表都没有符合主叫的记录则输出类型为:呼转
o_moneys:=27900;
--这个phone_xlt表的查询真不知道该放在哪里
select flag into o_flag from phone_xlt where tele=substr(p_tele,1,4); --判断小灵通号码前四位
case o_flag
when 1 then o_moneys:=3000;
end case;
if substr(p_tele,2,1) in ('0','1','9')
then o_flag:=2;o_moneys:=27900; --以上两表都没有符合主叫的记录则判断主叫的第二位,符合条件则输出类型为:公户
end if;
--以上判断主叫p_tele的电话类型
--以下判断主叫p_tele已消费的费用
select count(*) into o_count from phone_zk where tele=p_tele;
--select 1 from phone_zk where condition and rownum = 1;
if o_count>0 then
select moneys into already_moneys from phone_zk where tele=p_tele;
--if count(1)=0 then --如果phone_zk表里没有符合条件的记录那么返回o_moneys/3*60
-- already_moneys:=o_moneys/3*60
--end if;
if (o_moneys-already_moneys)>0 --大于零表示主叫p_tele已消费并且没有超出最大消费额度
then already_moneys:=(o_moneys-already_moneys)/3*60;
else --小于零表示主叫p_tele超出最大消费额度要限费,先判断被叫by_call是否限费
select xianfei into restrict from phone_bycall where call=by_call;
if restrict=0 and o_flag=1 --xianfei为0(不限制费用)并且主叫类型为私户
then
if (o_moneys-already_moneys)