oracle创建过程,以部门号为参数,输出比部门号平均工资低的员工姓名员工号。我写的程序总是带有编译错误
createorreplaceprocedurea(p-deptnoemp.deptno%TYPE)asv-salemp.sal%TYPEbeginselectavg(s...
create or replace procedure a(
p-deptno emp.deptno%TYPE)
as
v-sal emp.sal%TYPE
begin
select avg(salary) into v-sal from emp
where deptno=p-deptno;
for v-emp in (select * from emp
where deptno=p-deptno and sal>v-sal)loop
dbms-output.put-line(v-emp.empno||' '||
v-emp.ename);
end loop;
exception
when no-data-found then
dbms-output.put.line("the deptno doesn't exists!")
end a;
警告:创建的函数带有编译错误 展开
p-deptno emp.deptno%TYPE)
as
v-sal emp.sal%TYPE
begin
select avg(salary) into v-sal from emp
where deptno=p-deptno;
for v-emp in (select * from emp
where deptno=p-deptno and sal>v-sal)loop
dbms-output.put-line(v-emp.empno||' '||
v-emp.ename);
end loop;
exception
when no-data-found then
dbms-output.put.line("the deptno doesn't exists!")
end a;
警告:创建的函数带有编译错误 展开
2个回答
展开全部
create or replace procedure a(p_deptno emp.deptno%TYPE) as
v_sal emp.sal%TYPE;
begin
select avg(sal) into v_sal from emp where deptno=p_deptno;
for v_emp in (select * from emp where deptno=p_deptno and sal<v_sal) loop
dbms_output.put_line(to_char(v_emp.empno)||' '||v_emp.ename);
end loop;
exception when no_data_found then
dbms_output.put_line('the deptno doesn’‘t exists!');
end a;
错误地方:
1、所有不是减号“-”的地方都改为下划线“_”.
2、v_sal emp.sal%TYPE 后面缺分号“;”。
3、select avg(salary) into v_sal from emp 中salary”改为sal,后面缺分号“;”。
4、(select * from emp where deptno=p_deptno and sal>v_sal)中sal>v_sal改为sal<v_sal 。
5、(v-emp.empno||' '||v_emp.ename)中v_emp.empno改为to_char(v_emp.empno)。
6、dbms_output.put.line("th deptno doesn't exists!")中put.line改为put_line,缺分号“;”。
双引号改为单引号,doesn't改为doesn‘’t(两个单引号)。
v_sal emp.sal%TYPE;
begin
select avg(sal) into v_sal from emp where deptno=p_deptno;
for v_emp in (select * from emp where deptno=p_deptno and sal<v_sal) loop
dbms_output.put_line(to_char(v_emp.empno)||' '||v_emp.ename);
end loop;
exception when no_data_found then
dbms_output.put_line('the deptno doesn’‘t exists!');
end a;
错误地方:
1、所有不是减号“-”的地方都改为下划线“_”.
2、v_sal emp.sal%TYPE 后面缺分号“;”。
3、select avg(salary) into v_sal from emp 中salary”改为sal,后面缺分号“;”。
4、(select * from emp where deptno=p_deptno and sal>v_sal)中sal>v_sal改为sal<v_sal 。
5、(v-emp.empno||' '||v_emp.ename)中v_emp.empno改为to_char(v_emp.empno)。
6、dbms_output.put.line("th deptno doesn't exists!")中put.line改为put_line,缺分号“;”。
双引号改为单引号,doesn't改为doesn‘’t(两个单引号)。
展开全部
create or replace procedure a(
p-deptno emp.deptno%TYPE)
as
v-sal emp.sal%TYPE
begin
select avg(salary) into v-sal from emp
where deptno=p-deptno;
for v-emp in (select * from emp
where deptno=p-deptno and sal>v-sal)loop
dbms-output.put-line(v-emp.empno||' '||
v-emp.ename);
end loop;
exception
when no-data-found then
dbms-output.put.line("the deptno doesn't exists!");--少个“;”
end;--少个“end;”
end a;
p-deptno emp.deptno%TYPE)
as
v-sal emp.sal%TYPE
begin
select avg(salary) into v-sal from emp
where deptno=p-deptno;
for v-emp in (select * from emp
where deptno=p-deptno and sal>v-sal)loop
dbms-output.put-line(v-emp.empno||' '||
v-emp.ename);
end loop;
exception
when no-data-found then
dbms-output.put.line("the deptno doesn't exists!");--少个“;”
end;--少个“end;”
end a;
追问
还是不行啊,依然提示编译错误。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询