create or replace procedure prc_get_sex
(stuname student.name%type)
as
stusex student.sex%type;
begin
select sex into stusex from student where name=stuname;
dbms_output.put_line('學生' || stuname || '的性別為:' || stusex);
exception
when too_many_rows then
dbms_output.put_line('數據太多');
when no_data_found then
dbms_output.put_line('沒有找到數據');
when invalid_cursor then
dbms_output.put_line('無效的游標');
when zero_divide then
dbms_output.put_line('除數為零');
when dup_val_on_index then
dbms_output.put_line('唯一索引中插入了重復行');
when others then
dbms_output.put_line('出現異常');
end;
begin
prc_get_sex('張三');
end;
浙公網安備 33010602011771號