当前位置:数据库 > Oracle >>

oracle存储过程中-----PLS-00103:出现符号“/”在需要下列..解决

oracle存储过程中-----PLS-00103:出现符号“/”在需要下列..解决
 
oracle中编写一存储过程:出现如下错误,
[sql] 
PLS-00103:出现符号“/”在需要下列之一时:(  
 
经过各种谷歌百度,在存储过程中定义变量不允许使用关键字,而我定义了变量sum,导致错误。
经过编译后的过程代码为:
[sql] 
create or replace procedure avg_sal(result out char)  
is    
i number(5);  
summ number(20);       
countnum number(20);   
begin     
    i:=10;  
    while i<40 loop  
        i:= i+10;     
        select sum(salary),count(*) into summ countnum from emp where deptno=i;   
        result:=summ/countnum;  
    end loop;  
end;  
/  
 
 
[sql] 
declare   
i number(5);  
sum_sal number(20);   
begin   
i:=10;  
loop  
exit when(i>30);  
select sum(sal)/count(*) into sum_sal from emp  where deptno=i;   
dbms_output.put_line(i||'号平均工资:'||sum_sal);   
i:= i+10;  
end loop;   
end;  
/   
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,