create or replace procedure Issnoexistence(Hsno in Studentfile.sno%TYPE)
as declare
S_sno Studentfile.sno%TYPE;
begin
select sno into S_sno from Studentfile where sno=Hsno;
if S_sno is null then
dbms_output.put_line('该考号的学生不存在!');
end if;
end Issnoexistence; 其中
Hsno 是我要输入查询的考生考号,如果Studentfile表中没有就输出 “该考号的学生不存在”
为什么在编译时说 Warning: Procedure created with compilation errors.
请教高手????
as declare
S_sno Studentfile.sno%TYPE;
begin
select sno into S_sno from Studentfile where sno=Hsno;
if S_sno is null then
dbms_output.put_line('该考号的学生不存在!');
end if;
end Issnoexistence; 其中
Hsno 是我要输入查询的考生考号,如果Studentfile表中没有就输出 “该考号的学生不存在”
为什么在编译时说 Warning: Procedure created with compilation errors.
请教高手????
select sno into S_sno from Studentfile where sno=Hsno;
当它查询不到时会提示NO_DATA_FOUND这个错误已写入 file afiedt.buf 1 create or replace procedure Issnoexistence(Hsno in Studentfile.sno%TYPE)
2 as
3 S_sno Studentfile.sno%TYPE;
4 begin
5 select sno into S_sno from Studentfile where sno=Hsno;
6 --if S_sno is null then
7 --dbms_output.put_line('该考号的学生不存在!');
8 --end if;
9 exception
10 WHEN NO_DATA_FOUND THEN
11 dbms_output.put_line('该考号的学生不存在!');
12* end Issnoexistence;
SQL> /过程已创建。SQL> exec issnoexistence('dd');PL/SQL 过程已成功完成。SQL> set serveroutput on;
SQL> exec issnoexistence('dd');
该考号的学生不存在!PL/SQL 过程已成功完成。
2 as
3 i_sno integer;
4 begin
5 select count(sno) into i_sno from Studentfile where sno=Hsno;
6 if i_sno=0 then
7 dbms_output.put_line('该考号的学生不存在!');
8 end if;
9 end Issnoexistence;
10 /过程已创建。SQL> exec issnoexistence('dd');
该考号的学生不存在!PL/SQL 过程已成功完成。