还有异常内没有语句也不编译
10 个解决方案
#1
看看这个
http://www.****.net/Develop/Article/18/18488.shtm
http://www.****.net/Develop/Article/18/18488.shtm
#2
09:20:09 SQL> set serveroutput on;
09:20:41 SQL> declare
09:20:45 2 t_col2 varchar2(20);
09:20:45 3 begin
09:20:45 4 for n in 1..10 loop
09:20:45 5 begin
09:20:45 6 select 'aaa' into t_col2 from dual;
09:20:45 7 DBMS_OUTPUT.PUT_LINE('col2 is:'||t_col2);
09:20:45 8 exception when no_data_found then
09:20:45 9 DBMS_OUTPUT.PUT_LINE('col2 is:null');
09:20:45 10 end;
09:20:45 11 end loop;
09:20:45 12 end;
09:20:45 13 /
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
PL/SQL 过程已成功完成。
实际:430
09:20:45 SQL>
09:20:41 SQL> declare
09:20:45 2 t_col2 varchar2(20);
09:20:45 3 begin
09:20:45 4 for n in 1..10 loop
09:20:45 5 begin
09:20:45 6 select 'aaa' into t_col2 from dual;
09:20:45 7 DBMS_OUTPUT.PUT_LINE('col2 is:'||t_col2);
09:20:45 8 exception when no_data_found then
09:20:45 9 DBMS_OUTPUT.PUT_LINE('col2 is:null');
09:20:45 10 end;
09:20:45 11 end loop;
09:20:45 12 end;
09:20:45 13 /
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
PL/SQL 过程已成功完成。
实际:430
09:20:45 SQL>
#3
应该是你自己写错了,你最好把代码贴出来看看
#4
认真点找找是否有不对应的标示符,不如:begin ... end ; if ... end if;等是否都对应。
#5
create or replace procedure ShowRePort_AD as
cursor uccursor is
select clie_id,uc_id,oper_id,uc_code,uc_code1,uc_sm
from telcom.user_charge
where oper_id,1,substr(7)in('a002002','a002005');
-- ucrecord uccursor%rowtype;
Rep_id telcom.report_IP.rep_id%type:='0';
clieid telcom.user_charge.clie_id%type;
ucid telcom.user_charge.uc_id%type;
operid telcom.user_charge.oper_id%type;
code telcom.user_charge.uc_code%type;
code1 telcom.user_charge.uc_code1%type;
sm telcom.user_charge.uc_sm%type;
Ccompanyname telcom.client.clie_companyname%type;
Ctaddress telcom.client.clie_taddress%type;
Cphone telcom.client.clie_phone%type;
Cname telcom.client.clie_name%type;
Csort telcom.client.clie_sort%type;
money telcom.clie_account.cla_money%type;
state telcom.client_suffer.cls_state%type;
clsstr varchar2(50);
TSPhone telcom.client_trust.clit_phone%type;
nPhone number(8);
burname telcom.business_relate.bur_name%type;
clstime telcom.client_suffer.cls_time%type;
clstime2 telcom.client_suffer.cls_time%type;
nclstime number(5);
empcode telcom.report_ad.emp_code%type;
empname telcom.employee.emp_name%type;
nName number(5);
begin
dbms_utility.exec_ddl_statement('truncate table report_ad');
for uccursor_rec in uccursor loop
---------------------------------
money:=null;
state:=null; TSPhone:=null;
burname:=null;clstime:=null;
clstime2:=null; Clsstr:=null;
empcode:=null; empname:=null;
----------------------------------
Rep_id:=to_char(to_number(Rep_id)+1);
clieid:=uccursor_rec.clie_id;
ucid:=uccursor_rec.uc_id;
operid:=uccursor_rec.oper_id;
code:=uccursor_rec.uc_code;
code1:=uccursor_rec.uc_code1;
sm:=uccursor_rec.uc_sm;
select clie_companyname,clie_taddress,clie_phone,clie_name,clie_sort
into Ccompanyname,Ctaddress,Cphone,Cname,Csort
from telcom.client where client.clie_id=clieid;
select cla_money into money from telcom.clie_account
where to_number(cla_id)= (select max(to_number(cla_id))
from telcom.clie_account where uc_id=ucid);
select cls_state into state from telcom.client_suffer
where to_number(cls_id)= (select max(to_number(cls_id))
from telcom.client_suffer where uc_id=ucid);
statetostr(State,ClsStr);
select count(*) into nclstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';--
if nclstime=0 then
select cls_time into clstime2 from telcom.client_suffer
where uc_id=ucid and cls_state='a';
clstime:=null;
else
select cls_time into clstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';
clstime2:=null;
end if;
select count(*) into nPhone from telcom.client_trust
where uc_id=ucid and clit_state='1';--
if nPhone<>0 then
select clit_Phone into TSPhone from client_trust where to_number(clit_id)=
(select max(to_number(clit_id)) from client_trust
where uc_id=ucid and clit_state='1');
else
TSPhone:=null;
end if;
select substr(BUR_NAME,1,length(bur_name)-4) into burname from telcom.business_relate
where business_relate.oper_id=operid and sort_id='1';
select emp_id2 into empcode from telcom.clientpratice
where clientpratice.uc_id=ucid;
select count(emp_name) into nName from telcom.employee
where emp_code=empcode;--
if nName=0 then
empname:=null;
else
select emp_name into empname from telcom.employee
where emp_code=empcode;
end if;
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
end loop;
exception
when no_data_found then
begin
insert into text values('异常',sysdate);
end;
end;
cursor uccursor is
select clie_id,uc_id,oper_id,uc_code,uc_code1,uc_sm
from telcom.user_charge
where oper_id,1,substr(7)in('a002002','a002005');
-- ucrecord uccursor%rowtype;
Rep_id telcom.report_IP.rep_id%type:='0';
clieid telcom.user_charge.clie_id%type;
ucid telcom.user_charge.uc_id%type;
operid telcom.user_charge.oper_id%type;
code telcom.user_charge.uc_code%type;
code1 telcom.user_charge.uc_code1%type;
sm telcom.user_charge.uc_sm%type;
Ccompanyname telcom.client.clie_companyname%type;
Ctaddress telcom.client.clie_taddress%type;
Cphone telcom.client.clie_phone%type;
Cname telcom.client.clie_name%type;
Csort telcom.client.clie_sort%type;
money telcom.clie_account.cla_money%type;
state telcom.client_suffer.cls_state%type;
clsstr varchar2(50);
TSPhone telcom.client_trust.clit_phone%type;
nPhone number(8);
burname telcom.business_relate.bur_name%type;
clstime telcom.client_suffer.cls_time%type;
clstime2 telcom.client_suffer.cls_time%type;
nclstime number(5);
empcode telcom.report_ad.emp_code%type;
empname telcom.employee.emp_name%type;
nName number(5);
begin
dbms_utility.exec_ddl_statement('truncate table report_ad');
for uccursor_rec in uccursor loop
---------------------------------
money:=null;
state:=null; TSPhone:=null;
burname:=null;clstime:=null;
clstime2:=null; Clsstr:=null;
empcode:=null; empname:=null;
----------------------------------
Rep_id:=to_char(to_number(Rep_id)+1);
clieid:=uccursor_rec.clie_id;
ucid:=uccursor_rec.uc_id;
operid:=uccursor_rec.oper_id;
code:=uccursor_rec.uc_code;
code1:=uccursor_rec.uc_code1;
sm:=uccursor_rec.uc_sm;
select clie_companyname,clie_taddress,clie_phone,clie_name,clie_sort
into Ccompanyname,Ctaddress,Cphone,Cname,Csort
from telcom.client where client.clie_id=clieid;
select cla_money into money from telcom.clie_account
where to_number(cla_id)= (select max(to_number(cla_id))
from telcom.clie_account where uc_id=ucid);
select cls_state into state from telcom.client_suffer
where to_number(cls_id)= (select max(to_number(cls_id))
from telcom.client_suffer where uc_id=ucid);
statetostr(State,ClsStr);
select count(*) into nclstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';--
if nclstime=0 then
select cls_time into clstime2 from telcom.client_suffer
where uc_id=ucid and cls_state='a';
clstime:=null;
else
select cls_time into clstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';
clstime2:=null;
end if;
select count(*) into nPhone from telcom.client_trust
where uc_id=ucid and clit_state='1';--
if nPhone<>0 then
select clit_Phone into TSPhone from client_trust where to_number(clit_id)=
(select max(to_number(clit_id)) from client_trust
where uc_id=ucid and clit_state='1');
else
TSPhone:=null;
end if;
select substr(BUR_NAME,1,length(bur_name)-4) into burname from telcom.business_relate
where business_relate.oper_id=operid and sort_id='1';
select emp_id2 into empcode from telcom.clientpratice
where clientpratice.uc_id=ucid;
select count(emp_name) into nName from telcom.employee
where emp_code=empcode;--
if nName=0 then
empname:=null;
else
select emp_name into empname from telcom.employee
where emp_code=empcode;
end if;
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
end loop;
exception
when no_data_found then
begin
insert into text values('异常',sysdate);
end;
end;
#6
在游标循环内不能编译
#7
试试
.................
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
exception
when others then
insert into text values('异常',sysdate);
end loop;
end;
.................
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
exception
when others then
insert into text values('异常',sysdate);
end loop;
end;
#8
这样也编译不过去
#9
什么错误?
#10
PLS-00103:出现符号"exception"在需要下列之一时:begindeclareendexit forgotoifloopmodnu
#1
看看这个
http://www.****.net/Develop/Article/18/18488.shtm
http://www.****.net/Develop/Article/18/18488.shtm
#2
09:20:09 SQL> set serveroutput on;
09:20:41 SQL> declare
09:20:45 2 t_col2 varchar2(20);
09:20:45 3 begin
09:20:45 4 for n in 1..10 loop
09:20:45 5 begin
09:20:45 6 select 'aaa' into t_col2 from dual;
09:20:45 7 DBMS_OUTPUT.PUT_LINE('col2 is:'||t_col2);
09:20:45 8 exception when no_data_found then
09:20:45 9 DBMS_OUTPUT.PUT_LINE('col2 is:null');
09:20:45 10 end;
09:20:45 11 end loop;
09:20:45 12 end;
09:20:45 13 /
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
PL/SQL 过程已成功完成。
实际:430
09:20:45 SQL>
09:20:41 SQL> declare
09:20:45 2 t_col2 varchar2(20);
09:20:45 3 begin
09:20:45 4 for n in 1..10 loop
09:20:45 5 begin
09:20:45 6 select 'aaa' into t_col2 from dual;
09:20:45 7 DBMS_OUTPUT.PUT_LINE('col2 is:'||t_col2);
09:20:45 8 exception when no_data_found then
09:20:45 9 DBMS_OUTPUT.PUT_LINE('col2 is:null');
09:20:45 10 end;
09:20:45 11 end loop;
09:20:45 12 end;
09:20:45 13 /
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
col2 is:aaa
PL/SQL 过程已成功完成。
实际:430
09:20:45 SQL>
#3
应该是你自己写错了,你最好把代码贴出来看看
#4
认真点找找是否有不对应的标示符,不如:begin ... end ; if ... end if;等是否都对应。
#5
create or replace procedure ShowRePort_AD as
cursor uccursor is
select clie_id,uc_id,oper_id,uc_code,uc_code1,uc_sm
from telcom.user_charge
where oper_id,1,substr(7)in('a002002','a002005');
-- ucrecord uccursor%rowtype;
Rep_id telcom.report_IP.rep_id%type:='0';
clieid telcom.user_charge.clie_id%type;
ucid telcom.user_charge.uc_id%type;
operid telcom.user_charge.oper_id%type;
code telcom.user_charge.uc_code%type;
code1 telcom.user_charge.uc_code1%type;
sm telcom.user_charge.uc_sm%type;
Ccompanyname telcom.client.clie_companyname%type;
Ctaddress telcom.client.clie_taddress%type;
Cphone telcom.client.clie_phone%type;
Cname telcom.client.clie_name%type;
Csort telcom.client.clie_sort%type;
money telcom.clie_account.cla_money%type;
state telcom.client_suffer.cls_state%type;
clsstr varchar2(50);
TSPhone telcom.client_trust.clit_phone%type;
nPhone number(8);
burname telcom.business_relate.bur_name%type;
clstime telcom.client_suffer.cls_time%type;
clstime2 telcom.client_suffer.cls_time%type;
nclstime number(5);
empcode telcom.report_ad.emp_code%type;
empname telcom.employee.emp_name%type;
nName number(5);
begin
dbms_utility.exec_ddl_statement('truncate table report_ad');
for uccursor_rec in uccursor loop
---------------------------------
money:=null;
state:=null; TSPhone:=null;
burname:=null;clstime:=null;
clstime2:=null; Clsstr:=null;
empcode:=null; empname:=null;
----------------------------------
Rep_id:=to_char(to_number(Rep_id)+1);
clieid:=uccursor_rec.clie_id;
ucid:=uccursor_rec.uc_id;
operid:=uccursor_rec.oper_id;
code:=uccursor_rec.uc_code;
code1:=uccursor_rec.uc_code1;
sm:=uccursor_rec.uc_sm;
select clie_companyname,clie_taddress,clie_phone,clie_name,clie_sort
into Ccompanyname,Ctaddress,Cphone,Cname,Csort
from telcom.client where client.clie_id=clieid;
select cla_money into money from telcom.clie_account
where to_number(cla_id)= (select max(to_number(cla_id))
from telcom.clie_account where uc_id=ucid);
select cls_state into state from telcom.client_suffer
where to_number(cls_id)= (select max(to_number(cls_id))
from telcom.client_suffer where uc_id=ucid);
statetostr(State,ClsStr);
select count(*) into nclstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';--
if nclstime=0 then
select cls_time into clstime2 from telcom.client_suffer
where uc_id=ucid and cls_state='a';
clstime:=null;
else
select cls_time into clstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';
clstime2:=null;
end if;
select count(*) into nPhone from telcom.client_trust
where uc_id=ucid and clit_state='1';--
if nPhone<>0 then
select clit_Phone into TSPhone from client_trust where to_number(clit_id)=
(select max(to_number(clit_id)) from client_trust
where uc_id=ucid and clit_state='1');
else
TSPhone:=null;
end if;
select substr(BUR_NAME,1,length(bur_name)-4) into burname from telcom.business_relate
where business_relate.oper_id=operid and sort_id='1';
select emp_id2 into empcode from telcom.clientpratice
where clientpratice.uc_id=ucid;
select count(emp_name) into nName from telcom.employee
where emp_code=empcode;--
if nName=0 then
empname:=null;
else
select emp_name into empname from telcom.employee
where emp_code=empcode;
end if;
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
end loop;
exception
when no_data_found then
begin
insert into text values('异常',sysdate);
end;
end;
cursor uccursor is
select clie_id,uc_id,oper_id,uc_code,uc_code1,uc_sm
from telcom.user_charge
where oper_id,1,substr(7)in('a002002','a002005');
-- ucrecord uccursor%rowtype;
Rep_id telcom.report_IP.rep_id%type:='0';
clieid telcom.user_charge.clie_id%type;
ucid telcom.user_charge.uc_id%type;
operid telcom.user_charge.oper_id%type;
code telcom.user_charge.uc_code%type;
code1 telcom.user_charge.uc_code1%type;
sm telcom.user_charge.uc_sm%type;
Ccompanyname telcom.client.clie_companyname%type;
Ctaddress telcom.client.clie_taddress%type;
Cphone telcom.client.clie_phone%type;
Cname telcom.client.clie_name%type;
Csort telcom.client.clie_sort%type;
money telcom.clie_account.cla_money%type;
state telcom.client_suffer.cls_state%type;
clsstr varchar2(50);
TSPhone telcom.client_trust.clit_phone%type;
nPhone number(8);
burname telcom.business_relate.bur_name%type;
clstime telcom.client_suffer.cls_time%type;
clstime2 telcom.client_suffer.cls_time%type;
nclstime number(5);
empcode telcom.report_ad.emp_code%type;
empname telcom.employee.emp_name%type;
nName number(5);
begin
dbms_utility.exec_ddl_statement('truncate table report_ad');
for uccursor_rec in uccursor loop
---------------------------------
money:=null;
state:=null; TSPhone:=null;
burname:=null;clstime:=null;
clstime2:=null; Clsstr:=null;
empcode:=null; empname:=null;
----------------------------------
Rep_id:=to_char(to_number(Rep_id)+1);
clieid:=uccursor_rec.clie_id;
ucid:=uccursor_rec.uc_id;
operid:=uccursor_rec.oper_id;
code:=uccursor_rec.uc_code;
code1:=uccursor_rec.uc_code1;
sm:=uccursor_rec.uc_sm;
select clie_companyname,clie_taddress,clie_phone,clie_name,clie_sort
into Ccompanyname,Ctaddress,Cphone,Cname,Csort
from telcom.client where client.clie_id=clieid;
select cla_money into money from telcom.clie_account
where to_number(cla_id)= (select max(to_number(cla_id))
from telcom.clie_account where uc_id=ucid);
select cls_state into state from telcom.client_suffer
where to_number(cls_id)= (select max(to_number(cls_id))
from telcom.client_suffer where uc_id=ucid);
statetostr(State,ClsStr);
select count(*) into nclstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';--
if nclstime=0 then
select cls_time into clstime2 from telcom.client_suffer
where uc_id=ucid and cls_state='a';
clstime:=null;
else
select cls_time into clstime from telcom.client_suffer
where uc_id=ucid and cls_state='ka';
clstime2:=null;
end if;
select count(*) into nPhone from telcom.client_trust
where uc_id=ucid and clit_state='1';--
if nPhone<>0 then
select clit_Phone into TSPhone from client_trust where to_number(clit_id)=
(select max(to_number(clit_id)) from client_trust
where uc_id=ucid and clit_state='1');
else
TSPhone:=null;
end if;
select substr(BUR_NAME,1,length(bur_name)-4) into burname from telcom.business_relate
where business_relate.oper_id=operid and sort_id='1';
select emp_id2 into empcode from telcom.clientpratice
where clientpratice.uc_id=ucid;
select count(emp_name) into nName from telcom.employee
where emp_code=empcode;--
if nName=0 then
empname:=null;
else
select emp_name into empname from telcom.employee
where emp_code=empcode;
end if;
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
end loop;
exception
when no_data_found then
begin
insert into text values('异常',sysdate);
end;
end;
#6
在游标循环内不能编译
#7
试试
.................
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
exception
when others then
insert into text values('异常',sysdate);
end loop;
end;
.................
insert into Report_AD(Rep_Id,Clie_Companyname,Clie_Phone,Clie_Name,
Clie_Sort,Clie_Taddress,Uc_Code,uc_code1,Uc_Sm,Cla_Money,Cls_State,clit_phone,Ctime,
uc_id,Oper_Id,Bur_Name,Cls_Time,Cls_Time2,Emp_Code,Emp_Name)
values(Rep_id,Ccompanyname,Cphone,Cname,
Csort,Ctaddress,code,code1,sm,money,Clsstr,TSPhone,sysdate,
ucid,operid,burname,clstime,clstime2,empcode,empname);
exception
when others then
insert into text values('异常',sysdate);
end loop;
end;
#8
这样也编译不过去
#9
什么错误?
#10
PLS-00103:出现符号"exception"在需要下列之一时:begindeclareendexit forgotoifloopmodnu