数据库(十一)
--根据学生选课题目写一个存储过程,输入教师编号
--判断所教学生的及格率,80分及格,如果及格率超过
--50%,职称上升一级,否则降一级
alter proc pingji
@tno varchar(20)
as
begin
declare @cno varchar(20)
select @cno=cno from Course where Tno=@tno
declare @yxcount int
select @yxcount=count(*) from Score where Cno=@cno and Degree>=70
declare @zcount int
select @zcount=COUNT(*) from Score where Cno=@cno
declare @prof varchar(20)
select @prof=prof from Teacher where Tno=@tno
if @zcount>0
begin
if @yxcount/@zcount>=0.5
begin
if @prof=‘教授‘
begin
print‘已经是最高级别,没法再升级了。‘
end
if @prof=‘副教授‘
begin
update Teacher set Prof=‘教授‘ where Tno=@tno
end
if @prof=‘讲师‘
begin
update Teacher set Prof=‘副教授‘ where Tno=@tno
end
if @prof=‘助教‘
begin
update Teacher set Prof=‘讲师‘ where Tno=@tno
end
if @prof=‘后勤‘
begin
update Teacher set Prof=‘助教‘ where Tno=@tno
end
end
else
begin
if @prof=‘教授‘
begin
update Teacher set Prof=‘副教授‘ where Tno=@tno
end
if @prof=‘副教授‘
begin
update Teacher set Prof=‘讲师‘ where Tno=@tno
end
if @prof=‘讲师‘
begin
update Teacher set Prof=‘助教‘ where Tno=@tno
end
if @prof=‘助教‘
begin
update Teacher set Prof=‘后勤‘ where Tno=@tno
end
end
end
else
begin
print‘这个老师可能没有教课‘
end
end
go
exec pingji ‘804‘
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。