zoukankan      html  css  js  c++  java
  • 数据库(十一)

    --根据学生选课题目写一个存储过程,输入教师编号
    --判断所教学生的及格率,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'

  • 相关阅读:
    初识 MyBatis
    基于模板匹配的车牌识别
    完整java开发中JDBC连接数据库代码和步骤
    MyBatis 动态SQL
    最大子序列和问题
    二分搜索,欧几里德算法
    链表单链表
    UVA 12293 Box Game
    hdu 4565 so easy
    Bootstrap Table的使用 Cryst
  • 原文地址:https://www.cnblogs.com/mxx0426/p/4099191.html
Copyright © 2011-2022 走看看