想输入一个部门号 然后打印出相应的信息
create or replace procedure p(no in number)
as
begin
select * from emp where DEPTNO=no;
end procedure;Warning: Procedure created with compilation errors.
不过老报错 看看哪里出了问题
create or replace procedure p(no in number)
as
begin
select * from emp where DEPTNO=no;
end procedure;Warning: Procedure created with compilation errors.
不过老报错 看看哪里出了问题
as
begin
select * from emp where DEPTNO=no;
end procedure;
红色部分改成 end p;
打印出相应的信息可以用DBMS_OUTPUT 蓝色部分可以用以下替代
create or replace procedure p(no in number)
as
v1 varchar2(100);
begin
select emp.ename into v1 from emp where DEPTNO=no;
dbms_output.put_line(v1 );
end p;
as
begin
select * from emp where DEPTNO='no';
end p;
表的结构是什么样子呢?不知道这两点就没办法帮你写了
指出你的错误好了
1
END P; 而不是END PROCEDURE;
2
在PL/SQL块中打印输出要用dbms_output.put_line()来实现
不能像平常一样一个SELECT就输出了写法可以参照#3的
as
particular emp%rowtype;
begin
select * into particular from emp where DEPTNO=p_no;
dbms_output.put_line(particular.empno||' '||particular.ename||' '||particular.sal);
end p;
as
v1 varchar2(100);
begin
select emp.ename into v1 from emp where DEPTNO=no;
dbms_output.put_line(v1 );
end p;
这样的确能创建成功 但是执行不出来啊
set serveroutput on
再执行存储过程就能看到输出了
要用游标,一条记录就可以
只是给你举个例子,晕倒
不行你把这句话换掉
select emp.ename into v1 from emp where DEPTNO=no where rownum <2;
取多条中的一条