This code works, but I'm having a problem adding something to it. When I search a last name that I know is in the table it comes up. If I search off a name that is not in the table nothing happens. I would like for it to say: name not found once it has looped through. I have tried it but for some reason its not working. can someone help
Create or replace Package Body test as
procedure p_student(last_name varchar2)
is
rec_count number;
cursor c1 (c_last_name varchar) is
select * from student where (student_last_name) = (c_last_name);
sorry_no exception;
begin
for rec in c1(last_name) loop
rec_count :=rec_count + 1;
dbms_output.put_line('Name: '||rec.student_first_name||' '||
rec.student_last_name);
end loop;
if rec_count = 0 then
raise sorry_no;
end if;
exception
when others then
dbms_output.put_line('hello');
end;
end;
/
Create or replace Package Body test as
procedure p_student(last_name varchar2)
is
rec_count number;
cursor c1 (c_last_name varchar) is
select * from student where (student_last_name) = (c_last_name);
sorry_no exception;
begin
for rec in c1(last_name) loop
rec_count :=rec_count + 1;
dbms_output.put_line('Name: '||rec.student_first_name||' '||
rec.student_last_name);
end loop;
if rec_count = 0 then
raise sorry_no;
end if;
exception
when others then
dbms_output.put_line('hello');
end;
end;
/