ORACLE 存储过程 在此 SELECT 语句中缺少 INTO 子句,怎么办?
createorreplaceprocedurecp_DialSrvlevelStat(useridinint,bgdateindate,enddateindate,mo...
create or replace procedure cp_DialSrvlevelStat(
userid in int,
bgdate in date,
enddate in date,
month_ in int,
year_ in int,
isvalid in int )
is
begin
select userid,sum(to_number(servicelevel)) from trunklog where
(userid is null or userid = userid) and
(bgdate is null or dialtime >= bgdate) and
(enddate is null or dialtime >= enddate) and
(month_ is null or to_char(dialtime, 'mm ') = month_) and
(year_ is null or to_char(dialtime, 'yyyy ') = year_) and
(isvalid is null or servicetime > 0) group by userid;
end cp_DialSrvlevelStat;
执行提示错误:PLS-00428:在此 SELECT 语句中缺少 INTO 子句
请问应该怎么修改? 展开
userid in int,
bgdate in date,
enddate in date,
month_ in int,
year_ in int,
isvalid in int )
is
begin
select userid,sum(to_number(servicelevel)) from trunklog where
(userid is null or userid = userid) and
(bgdate is null or dialtime >= bgdate) and
(enddate is null or dialtime >= enddate) and
(month_ is null or to_char(dialtime, 'mm ') = month_) and
(year_ is null or to_char(dialtime, 'yyyy ') = year_) and
(isvalid is null or servicetime > 0) group by userid;
end cp_DialSrvlevelStat;
执行提示错误:PLS-00428:在此 SELECT 语句中缺少 INTO 子句
请问应该怎么修改? 展开
展开全部
select出来的结果要放到变量中去,select ... into .... from ... where ....
追问
谢谢,这个变量是自己声明,还是使用参数中的变量呢?
追答
理论上是都可以的,但是如果应用过程中,参数中的变量一般都是传进来的,所以已经有值,既然作为参数,肯定是利用传进来的值再到SELECT的WHERE条件中作为利用,您觉得呢?
SELECT出来的结果放到变量中,这个变量肯定是后声明的比较多,当然了,你也可以把SELECT出来的结果放到参数变量中替代传递进来的参数值。
展开全部
create or replace procedure cp_DialSrvlevelStat(
userid in int,
bgdate in date,
enddate in date,
month_ in int,
year_ in int,
isvalid in int )
is
--自己声明一个变量TEMP
TEMP VARCHAR2(128);
begin
--使用into 子句
select sum(to_number(servicelevel)) into TEMP from trunklog where
end cp_DialSrvlevelStat;
userid in int,
bgdate in date,
enddate in date,
month_ in int,
year_ in int,
isvalid in int )
is
--自己声明一个变量TEMP
TEMP VARCHAR2(128);
begin
--使用into 子句
select sum(to_number(servicelevel)) into TEMP from trunklog where
end cp_DialSrvlevelStat;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询