create or replace procedure query_employee1(eno number,name out varcahr2,sal out number)
is
begin
select ename,salary into name,sal from emp where deptno = eno;
exception when no_data_found then
raise_application_error(-20000,'该雇员不存在');
end;
执行过程:
SQL> var name varchar2(10);
SQL> var salary number;
SQL> exec query_employee1(7,:name,:salary)结果:
begin query_employee1(7,:name,:salary); end;
ORA-06550: 第 2 行, 第 7 列:
PLS-00905: 对象 BMS.QUERY_EMPLOYEE1 无效
ORA-06550: 第 2 行, 第 7 列:
PL/SQL: Statement ignored
name
---------
salary
---------为什么出这样的错误呢?
is
begin
select ename,salary into name,sal from emp where deptno = eno;
exception when no_data_found then
raise_application_error(-20000,'该雇员不存在');
end;
执行过程:
SQL> var name varchar2(10);
SQL> var salary number;
SQL> exec query_employee1(7,:name,:salary)结果:
begin query_employee1(7,:name,:salary); end;
ORA-06550: 第 2 行, 第 7 列:
PLS-00905: 对象 BMS.QUERY_EMPLOYEE1 无效
ORA-06550: 第 2 行, 第 7 列:
PL/SQL: Statement ignored
name
---------
salary
---------为什么出这样的错误呢?
红色俩变量,你未声明。
create or replace procedure query_employee1(eno number,name out varcahr2,sal out number)
is
v_name emp.ename%type;
v_sal emp.sal%type;
begin
select ename,salary into v_name,v_sal from emp where deptno = eno;
exception when no_data_found then
raise_application_error(-20000,'该雇员不存在');
end;
is
begin
select ename,sal into name,sal from emp where deptno = eno;
exception when no_data_found then
raise_application_error(-20000,'该雇员不存在');
end;没看见你在参数列表里定义,另外参数名最好不要和列名同。