create or replace procedure telnums(begintime date,endtime date) is
declare
v_cou number := (begintime-endtime)/60*12*1000;
v_i number:=0;
tel number;
begin
loop
exit when v_i>=v_cou;
select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
v_i:=v_i+1;
begintime:=begintime+5*60*1000;
end loop;
end;
declare
v_cou number := (begintime-endtime)/60*12*1000;
v_i number:=0;
tel number;
begin
loop
exit when v_i>=v_cou;
select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
v_i:=v_i+1;
begintime:=begintime+5*60*1000;
end loop;
end;
telnums(begintime out date,endtime date)2.检查一下SQL是否有效,表和字段是否存在。
select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
1.参数1在过程中有赋值,所有 应该给与 out.
telnums(begintime out date,endtime date)2.检查一下SQL是否有效,表和字段是否存在。
select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
SQL> create or replace procedure telnums1(begintime date,endtime date) is
2 v_cou number := (begintime-endtime)/60*12*1000;
3 v_i number:=0;
4 tel number;
5 begin
6 loop
7 exit when v_i>=v_cou;
8 select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
9 v_i:=v_i+1;
10 begintime:=begintime+5*60*1000;
11 end loop;
12 end;
13
14 /
Warning: Procedure created with compilation errors
SQL> show error
Errors for PROCEDURE IMSMON.TELNUMS1:
LINE/COL ERROR
-------- ------------------------------------------------------------------------
8/33 PL/SQL: ORA-00942: table or view does not exist
8/3 PL/SQL: SQL Statement ignored
10/3 PLS-00363: expression 'BEGINTIME' cannot be used as an assignment target
10/3 PL/SQL: Statement ignored
改成 create or replace procedure telnums1(begintime in out date,endtime date) 就不会报错了
PLS-00363,你的参数没有加in out修饰符,create or replace procedure telnums1(begintime date,endtime date)改成create or replace procedure telnums1(begintime in date,endtime in date)
as
v_cou number := (begintime-endtime)/60*12*1000;
v_i number:=0;
tel number;
tmp_time DATE;BEGIN
tmp_time := begintime;
loop
exit when v_i>=v_cou;
select count(*) into tel from ay_agent_log where AY_BEGIN_TIME=begintime;
v_i:=v_i+1;
--begintime:=begintime+5*60*1000; tmp_time:=tmp_time+5*60*1000; end loop;
end;
pls-00103:encountered the symbol "=" when expecting one of the follow:.;when
pls-00103:encountered the symbol "end"
create or replace procedure telnums(begintime IN date,endtime IN date)
as
v_cou number := (begintime-endtime)/60*12*1000;
v_i number:=0;
tel number;
tmp_time DATE;BEGIN
tmp_time := begintim……
[/Quote
已经好了 谢谢你哦