oracle模拟院校招生系统招生录取的过程(packages)

本文介绍了一个高考招生系统的详细设计,包括基本需求分析、数据库表结构、PL/SQL包头及包体实现等内容。系统覆盖了院校、招生部门及考生的需求,实现了志愿投档、考生分数查询等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基本需求分析
高考招生和录取工作,一般是由招生部门和院校合作完成的。招生部门和院校是该应用程序的使用者。该应用程序为考生只提供一些简单的查询功能。
1.院校
院校应提供招生的要求,如招生的人数、最低录取分数线以及对考生的其他条件的限制。
院校需要在录取结束后查询院校的录取名单。
2.招生部门
招生部门要收集和整理考生信息,建立考生信息库和院校信息库。考生信息库用于存取考生的基本信息,包括考生的高考成绩和报考志愿;院校信息库用于存取院校的基本信息和招生信息。
n招生部门需要在录取结束后统计所有院校的招生情况。
3.考生
考生在录取过程中需要查询其高考分数和录取状态。
相关表

学院信息表college

字段名称

类型

宽度

约束条件

简要说明

学院编号collegeid

number

5

主键

学院的编号

学院名称name

varchar2

50

不允许为空

学院的名称

录取分数线grade

number

3

>-1 and <701

院校最低录取分数线

计划招生人数plan_total

number

3

不允许为空

计划招生人数

录取人数actual_total

number

3

默认初值为0

已经录取的人数

联系人connector

varchar2

50

默认为空

联系人

联系电话tel

varchar2

20

默认为空

联系电话

地址address

varchar2

50

默认为空

学校地址

学生基本信息表student

字段名称

类型

宽度

约束条件

简要说明

考生考号stuid

number

5

主键

考生考号

考生姓名name

varchar2

50

不允许为空

考生姓名

年龄age

number

3

>-1,<151

年龄

性别sex

number

1

0-男,1-女

性别编号

家庭地址address

varchar2

50

默认为空

家庭地址

联系电话tel

varchar2

20

默认为空

联系电话

学生成绩表score

字段名称

类型

宽度

约束条件

简要说明

stuid

number

5

1.主键

2.外键,参照student表的stuid

考生考号

chinese

number

3

>-1,< 151

语文成绩

math

number

3

>-1,< 151

数学成绩

english

number

3

>-1,< 151

数学成绩

complex

number

3

>-1,< 251

综合成绩

学生录取情况表mat

字段名称

类型

宽度

约束条件

简单说明

编号stuid

number

5

1.主键

2.外键,参照student表的stuid

考生的编号

一志愿first_will

nubmer

5

外键,参照college的id

一志愿的院校编号, college的collegeid

二志愿second_will

number

5

外键,参照college的id

二志愿的院校编号, college的collegeid

是否同意调剂rel_flag

number

1

默认为0

是否同意调剂,

0-不同意,1-同意

录取状态mat_flag

number

1

默认为0

0-未录取,1-录取

状态,0-未录取,1-录取

录取院校mat_collegeid

number

5

外键,参照college的id

录取院校的院校编号,即college的collegeid

录取志愿mat_will_flag

number

1

默认为空

1代表一志愿,2代表二志愿,3代表调剂

表示考生被哪个志愿录取,1代表一志愿,2代表二志愿,3代表调剂

录取日期mat_date

date

默认为空

录取的日期

操作人operator

varchar2

50

默认为空

对考生投档的账户

package pag_zs 包头
create or replace package pag_zs is -- Author : ADMINISTRATOR -- Created : 2009-9-22 9:06:57 -- Purpose : --一志愿投档 /* 过程名和参数:proc1(p_collageid) 参数p_collageid: 要进行一志愿投挡的院校编号。 功能:完成该院校的一志愿投档录取的过程。 投档过程是:对一志愿报考该院校的、分数在最低录取分数线上的学生,按分数进行排序,根据招生人数取前几名录取。 本次录取的考生要回填状态和录取院校等信息,将考生信息表中录取状态改为录取,并将院校编号和录取志愿号(为1)填入考生表。同时将院校信息表中对应的录取人数做相应的修改,将实际录取的人数回填院校表的录取人数字段。*/ procedure proc1(p_collegeid in number); --二志愿投档 /* 过程名和参数:proc2(p_collageid) 参数p_collageid:要进行二志愿投档的院校编号 功能:该过程完成按照院校的要求对某院校进行二志愿投档和录取的过程。投档时要指定学院编号作为参数。 过程是:对二志愿报考该学院且还没有录取的(去掉一志愿录取的考生)、分数在最低录取分数线上的学生,按分数进行排序,根据缺额(招生人数去掉录取人数)取前几名录取。 本次录取的考生要回填状态和录取学院等信息,将考生信息表中录取状态改为录取,并将院校编号、录取志愿号(为2)填入考生表。同时将院校信息表中对应的录取人数做相应的修改,将实际录取的人数回填院校表的录取人数字段。*/ procedure proc2(p_collegeid in number); --自动投档程序 /* 过程名和参数:autoproc(will_number) 参数:will_number代表要进行录取的志愿,只能是1或2,1代表一志愿,2代表二志愿。 功能:该过程根据选定志愿,循环对所有院校进行投档,即对所有院校循环调用PROC1或PROC2。一次完成所有院校的一志愿或二志愿投档。 */ procedure autoproc(will_number in number); --查询考生分数过程 /* 过程名和参数: SHOW_SCORE(p_stuid) 其中,p_stuid代表考生编号。 功能:给出考生的考号,查出考生的姓名,总分, 各科成绩,所报院校编号,所报院校名称.(第一志愿的和二志愿的都需要显示出来)*/ procedure show_score(p_stuid in number); --查询考生录取状态过程 /* 过程名和参数:SHOW_RUSULT(p_stuid) 其中,p_stuid代表考生编号。 查询某学生的总分, 各科成绩, 录取情况(已录取,或未录取), 录取院校名称,第几志愿.*/ procedure show_result(p_stuid in number); --get_students /* 过程名和参数:get_students (stuid ) 注:stuid 为小明的准考证号. 假设小明已被某院校录取,找出该院校所录取的 学生中,总分比小明高的学生的相关信息: 总分,各科成绩,第几志愿录取等信息. 说明:要用到子查询 */ procedure get_students(p_stuid in number); --显示院校录取名单 /* 过程名和参数: STUDENT_LIST(P_collegeid) 其中,P_collegeid表示院校编号。 功能:指定院校编号,按总分排序, 显示该院校所招学生的总分,平均分,各科成绩,录取的志愿等相关信息. */ procedure student_list(p_collegeid in number); --院校招生情况统计 /* 过程名和参数:COLLEGE_TOTAL 功能:按照院校的平均录取分数排序所有院校,统计各院校的最高分数、最低分数,招生人数、录取人数、男生人数、女生人数等信息。*/ procedure college_total; --投档初始化过程 /* 过程名和参数: clear_status 功能:该过程用于在每次开始模拟录取前对考生录取情 况表和学院招生表进行状态初始化。 具体功能包括: 清空par_collage表的录取人数; 设置stu_mat学生录取情况表所有考生的录取状态为0(未录 取),录取院校为空,录取志愿为空,录取日期为空,操作人为空。 */ procedure clear_status; end pag_zs;
包体
create or replace package body pag_zs is --一志愿投档 procedure proc1(p_collegeid in number) as v_collegerow college%rowtype; cursor v_stulist(v_grade_tmp number,v_plantotal_tmp number,p_collegeid_tmp number) is select mat.stuid as stuid,first_will from score,mat where score.stuid=mat.stuid and chinese+math+english+complex>=v_grade_tmp and rownum<=v_plantotal_tmp and mat_flag=0 and rel_flag=0 and first_will=p_collegeid_tmp order by chinese+math+english+complex desc; begin select * into v_collegerow from college where collegeid=p_collegeid; dbms_output.put_line(v_collegerow.grade); --查询上线学生信息,执行录取操作 for v_record in v_stulist(v_collegerow.grade,(v_collegerow.plan_total-v_collegerow.actual_total),p_collegeid) loop dbms_output.put_line(v_record.stuid); --更新学生录取情况表 update mat set mat_flag=1, mat_collegeid=p_collegeid, mat_will_flag=1, mat_date=sysdate, operator='小陈' where stuid=v_record.stuid; --更新学院信息表 update college set actual_total=actual_total+1 where collegeid=p_collegeid; end loop; commit; exception when others then --v_grade:=0; rollback; dbms_output.put_line('error'); end proc1; --二志愿投档 procedure proc2(p_collegeid in number) as v_collegerow college%rowtype; cursor v_stulist(v_grade_tmp number,v_plantotal_tmp number,p_collegeid_tmp number) is select mat.stuid as stuid,second_will from score,mat where score.stuid=mat.stuid and chinese+math+english+complex>=v_grade_tmp and rownum<=v_plantotal_tmp and mat_flag=0 and rel_flag=0 and second_will=p_collegeid_tmp order by chinese+math+english+complex desc; begin select * into v_collegerow from college where collegeid=p_collegeid; dbms_output.put_line(v_collegerow.grade); --查询上线学生信息,执行录取操作 for v_record in v_stulist(v_collegerow.grade,(v_collegerow.plan_total-v_collegerow.actual_total),p_collegeid) loop dbms_output.put_line(v_record.stuid); --更新学生录取情况表 update mat set mat_flag=1, mat_collegeid=p_collegeid, mat_will_flag=2, mat_date=sysdate, operator='小陈' where stuid=v_record.stuid; --更新学院信息表 update college set actual_total=actual_total+1 where collegeid=p_collegeid; end loop; commit; exception when others then --v_grade:=0; rollback; dbms_output.put_line('error'); end proc2; --自动投档程序 procedure autoproc(will_number in number) as cursor v_college is select * from college; begin if(will_number=1) then for v_record in v_college loop --一志愿自动投档 proc1(v_record.collegeid); end loop; elsif (will_number=2) then --dbms_output.put_line('2'); for v_record in v_college loop --二志愿自动投档 proc2(v_record.collegeid); end loop; end if; commit; exception when others then rollback; end autoproc; --查询考生分数过程 procedure show_score(p_stuid in number) as --student_info type_student; v_stu view_studentinfo%rowtype; begin select stuid,name,totalscore, chinese,math,english,complex, first_will,first_will_name, second_will,second_will_name into v_stu from view_studentinfo where stuid=p_stuid; dbms_output.put_line(v_stu.stuid); dbms_output.put_line(v_stu.name); dbms_output.put_line(v_stu.totalscore); dbms_output.put_line(v_stu.chinese); dbms_output.put_line(v_stu.math); dbms_output.put_line(v_stu.english); dbms_output.put_line(v_stu.complex); dbms_output.put_line(v_stu.first_will); dbms_output.put_line(v_stu.first_will_name); dbms_output.put_line(v_stu.second_will); dbms_output.put_line(v_stu.second_will_name); exception when others then dbms_output.put_line('error'); end show_score; --查询考生录取状态过程 procedure show_result(p_stuid in number) as --student_info type_student; v_stu view_studentinfo_result%rowtype; begin select stuid,totalscore, chinese,math,english,complex, matflag,collegename,mat_will_flag into v_stu from view_studentinfo_result where stuid=p_stuid; dbms_output.put_line(v_stu.stuid); dbms_output.put_line(v_stu.totalscore); dbms_output.put_line(v_stu.chinese); dbms_output.put_line(v_stu.math); dbms_output.put_line(v_stu.english); dbms_output.put_line(v_stu.complex); dbms_output.put_line(v_stu.matflag); dbms_output.put_line('录取院校:'||v_stu.collegename); dbms_output.put_line('录取志愿:'||v_stu.mat_will_flag); exception when others then dbms_output.put_line('error'); end show_result; --get_students procedure get_students(p_stuid in number) is cursor v_stu is select * from view_studentinfo_all where mat_flag=1 and mat_collegeid=( select mat_collegeid from mat where stuid=p_stuid ) and totalscore>( select chinese+math+english+complex as totalscore from score where stuid=p_stuid ); begin for v_record in v_stu loop dbms_output.put_line(v_record.stuid); end loop; end get_students; --显示院校录取名单 procedure STUDENT_LIST(p_collegeid in number) as cursor v_stu is select stuid,name,totalscore,totalscore/4 as avgscore, chinese,math,english,complex, first_will,first_will_name,second_will,second_will_name, mat_flag,mat_collegeid,mat_will_flag from view_studentinfo_all where mat_collegeid=p_collegeid order by totalscore desc; score float:=0; i integer:=0; begin for v_record in v_stu loop dbms_output.put_line('报名序号:'||v_record.stuid||'姓名:'||v_record.name||'分数:'||v_record.totalscore||'志愿:'||v_record.mat_will_flag); score:=score+v_record.totalscore; i:=i+1; end loop; dbms_output.put_line('总分:'||score); dbms_output.put_line('平均分:'||score/i); end STUDENT_LIST; --院校招生情况统计 procedure COLLEGE_TOTAL as cursor v_cur is select mat_collegeid,avg(totalscore) as avgscore from view_studentinfo_all where mat_flag=1 group by mat_collegeid order by avgscore desc; max_min_score view_count_max_min%rowtype; collegeinfo college%rowtype; cursor v_num(p_collegeid_tmp number) is select count(*) as num from mat,student where mat_flag=1 and mat.stuid=student.stuid and mat.mat_collegeid=p_collegeid_tmp and student.sex=0 union select count(*) as num from mat,student where mat_flag=1 and mat.stuid=student.stuid and mat.mat_collegeid=p_collegeid_tmp and student.sex=1; begin for v_record in v_cur loop --统计各院校的最高分数、最低分数 select mat_collegeid,maxscore,minscore into max_min_score from view_count_max_min where mat_collegeid=v_record.mat_collegeid; dbms_output.put_line(max_min_score.mat_collegeid); dbms_output.put_line('最高分:'||max_min_score.maxscore||'最低分:'||max_min_score.minscore); --招生人数、录取人数 select * into collegeinfo from college where collegeid=v_record.mat_collegeid; dbms_output.put_line('计划招生数:'||collegeinfo.plan_total); dbms_output.put_line('实际录取数:'||collegeinfo.actual_total); --男生人数、女生人数 for v_record_2 in v_num(v_record.mat_collegeid) loop dbms_output.put_line(v_record_2.num); end loop; end loop; end COLLEGE_TOTAL; --投档初始化过程 procedure clear_status as begin update college set actual_total=0; update mat set mat_flag=0, mat_collegeid=null, mat_will_flag=null, mat_date=null, operator=null; commit; exception when others then rollback; end clear_status; end pag_zs;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值