题目要求:
1,创建student表和result表 2,pl/sql对学生的成绩数据进行处理 3,处理的逻辑是根据每门专业课的最低分线和总分的最低分数线自动的将录取和落选
1,创建student表,和result表
学生信息表;
create table student( student_id number primary key,--学生id math number,--数学分数 chinaese number,--语文分数 en number,--英语分数 wenke number,--文科学分 likenumber number,--理科分数 zhuanyeke number,--专业分数 student_sum number --总分 );
学生录取状态表;
create table result( student_id number, enrollresult number );
2.插入一些考生的数据
student表插入数据;
理科 insert into student(student_id,math,chinaese,en,likenumber,STUDNET_SUM) values(4307211993,120,130,140,260,650); insert into student(student_id,math,chinaese,en,likenumber,STUDNET_SUM) values(4307211997,20,30,40,260,350); insert into student(student_id,math,chinaese,en,likenumber,STUDNET_SUM) values(4307211998,120,30,240,130,520); 理科专业 insert into student(student_id,math,chinaese,en,likenumber,zhuanyeke,STUDNET_SUM) values(4307211994,128,128,138,260,200,844); insert into student(student_id,math,chinaese,en,likenumber,zhuanyeke,STUDNET_SUM) values(4307211999,120,30,40,130,180,500); insert into student(student_id,math,chinaese,en,likenumber,zhuanyeke,STUDNET_SUM) values(4307211100,20,30,13,157,180,400); 文科 insert into student(student_id,math,chinaese,en,wenke,STUDNET_SUM) values(4307211995,110,140,50,270,550); insert into student(student_id,math,chinaese,en,wenke,STUDNET_SUM) values(4307211101,90,80,50,180,400); insert into student(student_id,math,chinaese,en,wenke,STUDNET_SUM) values(4307211102,110,120,80,230,540); 文科专业 insert into student(student_id,math,chinaese,en,wenke,zhuanyeke,STUDNET_SUM) values(4307211996,120,30,40,160,180,530);
result表插入数据;
insert into result values(4307211993); insert into rasult values(4307211997); insert into rasult values(4307211998); insert into rasult values(4307211994); insert into rasult values(4307211999); insert into rasult values(4307211100);
3,编写带参数的存储过程,记录考生的分数以及保存考生的录取状态 0表示落选,1表示录取
create or replace procedure pro_score(v_id number) is v_student_id student.student_id%type; v_math student.math%type; v_chinaese student.chinaese%type; v_en student.en%type; v_wenke student.wenke%type; v_like student.likenumber%type; v_zhuanye student.zhuanyeke%type; v_score number(7); begin select STUDENT_ID, MATH ,CHINAESE,EN ,WENKE ,LIKENUMBER ,ZHUANYEKE into v_student_id , v_math,v_chinaese,v_en ,v_wenke,v_like,v_zhuanye from student where student_id=v_id; v_score := v_math + v_chinaese + v_en + v_wenke + v_like + v_zhuanye; dbms_output.put_line('总分'||v_score); if v_score>500 then update result set ENROLLRESULT=1 where STUDENT_ID=v_id; dbms_output.put_line(v_student_id||'被录取了'); else update result set ENROLLRESULT=0 where STUDENT_ID=v_id; dbms_output.put_line(v_student_id||'落榜了'); end if; end;
4,创建游标,用于从student表中查询数据,并加入一个异常机制 0表示落选,1表示录取
set serveroutput on; create or replace procedure pro_score is myrow student%rowtype; v_score number(7); type type_cursor is ref cursor; rowcursor type_cursor ; begin open rowcursor for select * from student; loop fetch rowcursor into myrow ; v_score := myrow.math + myrow.chinaese + myrow.en + nvl(myrow.wenke,0) + nvl(myrow.likenumber,0) +nvl( myrow.zhuanyeke,0); dbms_output.put_line('总分'||v_score); exit when rowcursor%notfound; if v_score>500 then update result set ENROLLRESULT=1 where STUDENT_ID=myrow.student_id; dbms_output.put_line(myrow.student_id||'被录取了'); else update result set ENROLLRESULT=0 where STUDENT_ID=myrow.student_id; dbms_output.put_line(myrow.student_id||'落榜了'); end if; end loop; end; /
exec pro_score;
总分650
4307211993被录取了
总分350
4307211997落榜了
总分520
4307211998被录取了
总分854
4307211994被录取了
总分500
4307211999落榜了
总分400
4307211100落榜了
总分570
4307211995被录取了
总分400
4307211101落榜了
总分540
4307211102被录取了
总分530
4307211996被录取了
总分530
在游标中添加异常机制,实在是不知道怎么添加了,所以把代码和思路贴出来让大家帮我看一下;怎么解决这个问题
相关推荐
Oracle模拟高考录取系统设计,完整的数据库设计,可以提供给学弟学妹参考和借鉴!
BLOG_Oracle_lhr_Oracle死锁的分类及其模拟.pdfBLOG_Oracle_lhr_Oracle死锁的分类及其模拟.pdf
考试模拟复习,主要是oracle的一些基本知识习题和上机练习
oracle sql 根据年份、周数取日期
模拟数据 oracle数据库,主要随机产生姓名,省份证,国际,住址等
oracle 数据库2份模拟试卷及答案 选择题 填空题
Oracle DBA基础考试模拟题Oracle DBA基础考试模拟题
Oracle 042和043的考试模拟软件, 打包下载, 绝对超值!
oracle OCA OCP 认证 007考试 模拟软件!很准
Oracle oca 051模拟考试题目,有答案。
Oracle PL-SQL 中联模拟笔试题
Oracle 1z0-051考试,OCA认证的第一阶段考试模拟题库。这个考试比较简单,而且可以无监考考试,大家可以参考练习
JavaGUI+Oracle实现的本地模拟学生成绩管理系统源码+数据库.zip适合新手入门,代码完整,下载可用。 JavaGUI+Oracle实现的本地模拟学生成绩管理系统源码+数据库.zip适合新手入门,代码完整,下载可用。JavaGUI+...
oracle根据生日自动求年龄的函数源代码,无须创建任何其他表
oracle ocp认证考试最新模拟题库043,帮助考生进行模拟测试,完全覆盖所有考题!
oracle模拟题,基本上包含所有基本问题 !
oracle12c模拟考试工具,完全和考试一致,有三种模式:练习,考试和自定义。非常好用,题库有500多道对oracle12c ocp的知识点全面覆盖,有了它完全可以做到心里有数,减少补考次数
ORACLE中科学计数法显示问题的解决,PLSQL显示超长数字的时候显示格式为科学计数法,此文档为解决方法
Oracle实例崩溃了、模拟崩溃后的恢复
用Oracle函数功能提高商贸模拟软件运行效率.pdf