ORACLE 过程编译错误,高手来解答!
这是什么错误,求解答!SQL>@package_body.sqlWarning:PackageBodycreatedwithcompilationerrors.SQL>s...
这是什么错误,求解答!
SQL> @package_body.sql
Warning: Package Body created with compilation errors.
SQL> show error
Errors for PACKAGE BODY EMP_PKG:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/14 PLS-00201: identifier 'EMP_PKG' must be declared
1/14 PLS-00304: cannot compile body of 'EMP_PKG' without its
specification
下面是建的包,以及包体的代码:
create package emp_pkg is
procedure update_sal(name varchar2,newsal number);
function annual_income(name varchar2) return number;
end;
create package body emp_pkg is
procedure update_sal(name varchar2,newsal number)
is
begin
update emp set sal=newsal
where lower(ename)=lower(name);
end;
function annual_income(name varchar2) return number
is
annual_salary number(7,2);
begin
select sal*12+nvl(comm,0) into annual_salary
from emp where lower(ename)=lower(name);
return annual_salary;
end;
end;
/ 展开
SQL> @package_body.sql
Warning: Package Body created with compilation errors.
SQL> show error
Errors for PACKAGE BODY EMP_PKG:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/14 PLS-00201: identifier 'EMP_PKG' must be declared
1/14 PLS-00304: cannot compile body of 'EMP_PKG' without its
specification
下面是建的包,以及包体的代码:
create package emp_pkg is
procedure update_sal(name varchar2,newsal number);
function annual_income(name varchar2) return number;
end;
create package body emp_pkg is
procedure update_sal(name varchar2,newsal number)
is
begin
update emp set sal=newsal
where lower(ename)=lower(name);
end;
function annual_income(name varchar2) return number
is
annual_salary number(7,2);
begin
select sal*12+nvl(comm,0) into annual_salary
from emp where lower(ename)=lower(name);
return annual_salary;
end;
end;
/ 展开
2个回答
展开全部
凭感觉,你的语法没错。今天连不起公司服务器。周一连上给你试试,等着。。
我们创建的时候,用的是create or replace package。我将你包的内容改变了(因为我没有创建你的那个数据表emp),运行成功了的。内容如下:
create or replace package xxemp_pkg is
procedure update_sal(name varchar2,newsal number);
function annual_income(name varchar2) return number;
end;
/
create or replace package body xxemp_pkg is
procedure update_sal(name varchar2,newsal number)
is
begin
/*update emp set sal=newsal
where lower(ename)=lower(name);*/null;
end;
function annual_income(name varchar2) return number
is
annual_salary number(7,2);
begin
/*select sal*12+nvl(comm,0) into annual_salary
from emp where lower(ename)=lower(name);*/null;
return annual_salary;
end;
end;
/
你再到你的系统试一试。
我们创建的时候,用的是create or replace package。我将你包的内容改变了(因为我没有创建你的那个数据表emp),运行成功了的。内容如下:
create or replace package xxemp_pkg is
procedure update_sal(name varchar2,newsal number);
function annual_income(name varchar2) return number;
end;
/
create or replace package body xxemp_pkg is
procedure update_sal(name varchar2,newsal number)
is
begin
/*update emp set sal=newsal
where lower(ename)=lower(name);*/null;
end;
function annual_income(name varchar2) return number
is
annual_salary number(7,2);
begin
/*select sal*12+nvl(comm,0) into annual_salary
from emp where lower(ename)=lower(name);*/null;
return annual_salary;
end;
end;
/
你再到你的系统试一试。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询