⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.txt

📁 4、 编写一个过程。要求:有一个输入参数和一个输出参数
💻 TXT
字号:
4、	编写一个过程。要求:有一个输入参数和一个输出参数,过程里面要有自定义异常。从学生表中(tab_student)中寻找符合指定学号等于输入参数的值,然后将找到的学生的姓名赋予输出参数,如果没有符合条件的值则触发异常。
Create table tab_student
(sno char(8),
sname varchar2(20),
age integer,
province varchar2(60),
sex char(4))
insert into tab_student values(‘001’,’zhou’,20,’江苏徐州’,’男’);
上述表已经创建,只需针对此表编写即可。

Create table tab_student(
sno char(8),
sname varchar2(20),
age integer,
province varchar2(60),
sex char(4)
);

insert into tab_student values('001','zhou',20,'江苏徐州','男');

create or replace procedure find_student
(i_sno in char , o_sname out varchar )
as
myException exception;
countstudent integer;
var_sname tab_student.sname%type;
begin
select count(*) into countstudent from tab_student where i_sno=sno;
if countstudent>0 then
select sname into var_sname from tab_student where i_sno=sno;
dbms_output.put_line(var_sname);
else
raise myException;
end if;
exception
when myException then
dbms_output.put_line('name not found!');
end find_student;

declare
var_studentname tab_student.sname%type;
begin
find_student('002',var_studentname);
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -