hc学习平台

 找回密码
 立即注册
搜索
热搜: 活动 交友 javakc
 › javav › 日志

编写带参数的存储过程,将百分制成绩,转换成绩等级’A’,’B’,’C’,’D’,’E’

2021-01-09 19:59:24 查看(385) 回复(0)

要求;

  1. 存储过程要有输入和输出

create procedure chengji( in n int , out result varchar    )
begin 
  declare result varchar(20);
 set n=truncate(rand()*100,0);
 case
  when n>90 then
   set result='A';
  when n>80 then
   set result='B';
  when n>70 then
   set result='C';
  when n>60 then
   set result='D';
  else
   set result='E';
 end case;
 select n,result ;

end;
call chengji;create procedure RiQi( in n int , out result varchar (20)   )
begin

 case n
  when 0 then
   set result='星期日';
  when 1 then
   set result='星期一';
  when 2 then
   set result='星期二';
  when 3 then
   set result='星期三';
  when 4 then
   set result='星期四';
  when 5 then
   set result='星期五';
  else
   set result='星期六';
 end case;

end;
call RiQi(0,@result);
select @result;

评论 (0 个评论)

facelist

全部作者的其他最新日志



站点统计|举报|Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, , Processed in 0.195171 second(s), 9 queries .

Powered by javakc! X1.0

© 2004-2014 javakc

f1208.com 备案号:京ICP备14030918号-1

返回顶部