Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exception problem

Status
Not open for further replies.

sirron

Programmer
Mar 11, 2004
139
0
0
US
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;
/
 
What do you mean not initialized?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top