版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、四川師范大學(xué)計(jì)算機(jī)學(xué)院實(shí) 驗(yàn) 報(bào) 告 冊(cè)院系名稱(chēng): 計(jì)算機(jī)科學(xué)學(xué)院 課程名稱(chēng): oracle 實(shí)驗(yàn)學(xué)期 2014 年至 2015 年 第 一 學(xué)期專(zhuān)業(yè)班級(jí): 網(wǎng)絡(luò)工程3班 姓名: 學(xué)號(hào): 指導(dǎo)教師: 俞曉 實(shí)驗(yàn)最終成績(jī): 實(shí)驗(yàn)一 了解oracle環(huán)境,使用oracle數(shù)據(jù)庫(kù)實(shí)用工具 1.目的要求: 了解oracle數(shù)據(jù)庫(kù)的各個(gè)常用工具軟件 2.實(shí)驗(yàn)內(nèi)容: 在oracel數(shù)據(jù)庫(kù)下使用sql*plus ,sql*plus worksheet,pl/sql developer工具,企業(yè)管理器等實(shí)用工具與oracle交互。并在企業(yè)管理器中觀察oracle的底層存儲(chǔ)原理。在pl/sql develope
2、r中書(shū)寫(xiě)簡(jiǎn)單的sql語(yǔ)言。 3.主要儀器設(shè)備及軟件 1)pc 2)oracle數(shù)據(jù)庫(kù) pl/sql developer工具的運(yùn)用:實(shí)驗(yàn)二 熟悉sql語(yǔ)言1.目的要求 在sql*plus或pl/sql developer工具中編寫(xiě)sql語(yǔ)句 2.實(shí)驗(yàn)內(nèi)容 oracle 數(shù)據(jù)庫(kù)中定義用戶,給用戶賦權(quán)限,創(chuàng)建,修改和刪除表格,視圖等數(shù)據(jù)庫(kù)對(duì)象,并向表格中插入,修改和刪除數(shù)據(jù)。體會(huì)sql語(yǔ)言中oracle的“方言”。 對(duì)自己建立的表做查詢(xún):包括單表查詢(xún),多表查詢(xún),嵌套查詢(xún),分組查詢(xún),相關(guān)查詢(xún) 掌握sql語(yǔ)句的書(shū)寫(xiě)方法熟練使用sql語(yǔ)句實(shí)現(xiàn)建表,修改表,刪除表,向表中插入,刪除,修改,查詢(xún)等操作。1.
3、創(chuàng)建用戶 create user lwq identified by 123;2. 給用戶賦權(quán)限 -連接權(quán)限: grant connect to lwq; -登錄數(shù)據(jù)庫(kù): connect lwq/123; -建表權(quán): grant create table to lwq; -若想將權(quán)限賦予所有用戶,可以使用public角色。如: grant select on sc to public;收回權(quán)限:revoke create table from lwq; 3. 創(chuàng)建表create table student(sno char(10) primary key ,sname varchar(20)
4、not null,sage smallint,ssex char(2),sdept varchar(20); create table course (cno char(10), primary key (cno) ,cname varchar(20) , cpno char(10),credit smallint ); create table sc (sno char(10),cno char(10),grade smallint,primary key (sno, cno) ); 4. 修改表-向已經(jīng)存在的表中添加屬性: alter table student add avg_grade
5、 number;-刪除一列:alter table student drop cloumn avg_grade;-修改屬性及相應(yīng)數(shù)據(jù): alter table student modify sage varchar(30);5. 刪除表格drop table student;6. dml數(shù)據(jù)庫(kù)的修改: 向表中插入,刪除,修改,查詢(xún)等操作-向表中插入數(shù)據(jù):insert into student values(001,張四,20,男,cs);insert into student values(002,劉五,19,女,is);-刪除數(shù)據(jù):delete from student where sno
6、= 001;-修改數(shù)據(jù):update student set age = age + 1 where sno = 002;update sc set grade = 90 where sno = 001 and cno = 1001;-查詢(xún):select * from sc; select cno from course where cname=數(shù)據(jù)庫(kù); select * from student where sname like 李%;-為結(jié)果集中的某個(gè)屬性改名:select pno as 產(chǎn)品號(hào),pname 名字,place 產(chǎn)地 from p;-列出jkx系中的女生的學(xué)號(hào)、姓名、身高,并
7、按身高進(jìn)行排列(降序): select sno,sname,heigh from student where sdept=jkx and ssex=女 order by heigh desc;-查詢(xún)成績(jī)小于60的10位同學(xué)的學(xué)號(hào),課程號(hào),成績(jī): select * from (select * from sc where grade60 order by grade desc) where rownum=10;7. 建視圖-建立學(xué)生平均成績(jī)視圖:create view avg_grade(sno,avgs) as select sno,avg(grade) from sc group by sn
8、o-找出平均成績(jī)小于89的學(xué)生select * from sc where avg(grade)=all(select sage from student);-2、求每一個(gè)學(xué)生的最高分和最低分。select sc.sno,sname,max(grade) maxgrade,min(grade) mingrade from sc,student where sc.sno=student.sno group by sc.sno,sname;-3、查詢(xún)cs系所有男同學(xué)考c05課程的成績(jī),列出這些學(xué)生的學(xué)號(hào),姓名,成績(jī),并按成績(jī)降序排列。select student.sno,sname,grade f
9、rom sc,student where sc.sno=student.sno and sdept=cs and ssex=男 and cno=c05 order by grade desc;-4、檢索選修了“數(shù)據(jù)庫(kù)”課程的學(xué)生的姓名(可用子查詢(xún)in或exists)select sname from student where exists (select * from sc where sno=student.sno and cno=( select cno from course where cname=數(shù)據(jù)庫(kù));select sname from student,sc,course wh
10、ere student.sno=sc.sno and o=o and cname=數(shù)據(jù)庫(kù)-(方法二)select sname from student where sno in (select sno from sc where cno = ( select cno from course where cname=數(shù)據(jù)庫(kù));-(方法三)-5、檢索選修了課程號(hào)為c01或c02課程,且成績(jī)高于或等于70分的學(xué)生的姓名,課程名和成績(jī)。select sname,cname,grade from student,sc,course where student.sno=sc.sno and o=o and
11、 o in (c01,c02) and grade = 70;-6、檢索所有學(xué)生的姓名、所選課程的課程名和成績(jī)以及課程號(hào),并且按成績(jī)的降序和課程號(hào)的升序進(jìn)行排列(使用外連接將沒(méi)有選課的同學(xué)列出來(lái))。select sname,cname,o,grade from sc,student,course where sc.sno=student.sno and o=o order by grade desc, o asc;select student.sname,ame,sc.grade,o from ( student left join sc on (student.sno=sc.sno) lef
12、t join course on (o=o) order by sc.grade desc,o asc;-7. 列出沒(méi)有選課的學(xué)生姓名select sname from student where not exists (select * from sc where sno=student.sno);-8. 列出平均分最高的學(xué)生所在系的所有學(xué)生的姓名select sname from student where sdept=( select sdept from student where sno=( select sno from sc group by sno having avg(gra
13、de)=all(select avg(grade) from sc group by sno);select * from student where sdept=cm;-(檢查)-9.查詢(xún)cs系c05課程的成績(jī)比c05課程的平均分高的學(xué)生學(xué)號(hào)select student.sno,cno,grade from student,sc where student.sno=sc.sno and grade(select avg(grade) from sc where cno=c05 group by cno) and sdept=cs and cno=c05;select student.sno,
14、cno,grade from sc,student where sc.sno=student.sno and cno=c05 and sdept=cs;-(測(cè)試)-10.查詢(xún)既選修了c01又選修了c02的學(xué)生select sname from student where not exists (select * from course where cno in (c01,c02) and not exists (select * from sc where cno=o and sno=student.sno);-11.統(tǒng)計(jì)及格的課程數(shù)在四門(mén)以上的學(xué)生所選課程的平均成績(jī)。最后按降序列出平均成績(jī)名
15、次名單來(lái)。select sno,avg(grade) agrade from sc where sno in ( select sno from sc where grade=60 group by sno having count(cno)4) group by sno order by avg(grade) desc;-12.檢索所有cs系學(xué)生都選修了的課程(列出課程號(hào)) select cno from course wherenot exists (select * from student where sno in (select sno from student where sdep
16、t=cs) and not exists (select * from sc where sc.sno=student.sno and o=o);select sno,cno from sc where sno in (select sno from student where sdept =cs)-(檢查)-13.查詢(xún)年齡高于其所在系的平均年齡的學(xué)生姓名select sname,sdept from student x where sage( select avg(sage) from student y where y.sdept=x.sdept);-14.查詢(xún)每位同學(xué)的選課中成績(jī)最高的課
17、程對(duì)應(yīng)的學(xué)號(hào),姓名,課程名,成績(jī)select student.sno,student.sname,ame,x.grade from student,sc x,course where o=o and student.sno=x.sno and grade=( select max(grade) maxgrade from sc y where y.sno=x.sno);-15.為ma系學(xué)生選修必修課c05 insert into sc(sno,cno) select sno,c05 from student where sdept = ma and not exists (select * f
18、rom sc where sno=student.sno and cno=c05);-16.將cs系,c01課程學(xué)生的成績(jī)加10分update sc set grade=grade+10 where sno in (select sno from student where sdept=cs) and cno=c01;select * from sc where sno in (select sno from student where sdept=cs) and cno=c01-(檢查)-17.將每位同學(xué)的最低分加10分(選)update sc set grade=grade+10 wher
19、e grade=(select min(grade) from sc x where sno=sc.sno)select sno,min(grade) from sc group by sno-(檢查用)-18.將”數(shù)據(jù)庫(kù)”的選課記錄全部刪除delete from sc where cno=(select cno from course where cname=數(shù)據(jù)庫(kù));實(shí)驗(yàn)三 實(shí)現(xiàn)簡(jiǎn)單的pl/sql程序一.目的要求 編寫(xiě)簡(jiǎn)單的pl/sql程序,熟悉pl/sql編程環(huán)境 二.實(shí)驗(yàn)內(nèi)容 在sql*plus或pl/sql developer工具中編寫(xiě)pl/sql的簡(jiǎn)單程序,熟悉pl/sql的編程環(huán)
20、境和代碼結(jié)構(gòu)。實(shí)現(xiàn)與oracle數(shù)據(jù)庫(kù)交互,并捕獲和處理常見(jiàn)系統(tǒng)異常和用戶自定義異常。 1.熟悉pl/sql結(jié)構(gòu)pl/sql塊語(yǔ)句是由declare或begin開(kāi)始,以end結(jié)束,在pl/sql塊中不能直接使用ddl。2.循環(huán)控制語(yǔ)句的運(yùn)用(素?cái)?shù))/for循環(huán)declare i integer; j int; k int:=0;-標(biāo)志kbegin for i in 2.100 loop k:=0; for j in 2.i/2 loop if mod(i,j)=0 then k:=1;-將不是素?cái)?shù)的標(biāo)志k設(shè)為1 exit; end if; end loop; if k =0 then dbms
21、_output.put_line(i); end if; end loop;end;-while循環(huán) declare i integer; j int; -標(biāo)志k k初始為0 當(dāng)k值為1的時(shí)候 ,不是素?cái)?shù);值為0,是素?cái)?shù) k int := 0; begin for i in 2 . 100 loop k := 0; j := 2; while j = i / 2 loop -進(jìn)入while循環(huán) 求i除j的模,如果等于0則把k設(shè)為1,否則k=0 if mod(i, j) = 0 then k := 1; exit; end if; j := j + 1;-判斷之后繼續(xù)進(jìn)入循環(huán) end loop;
22、 - 判斷k的值,如果為0,則輸出i的值 if k = 0 then dbms_output.put_line(i); end if; end loop; end;捕獲異常(預(yù)定義異常處理)declare x number;begin x :=y;exception when value_error then dbms_output.put_line(value error); end;3.自定義異常declare vsno varchar2(20);sno_code exception;begin vsno := x; if vsno not in(a,b,c)then raise sno_
23、code; end if;exception when sno_code then dbms_output.put_line(vsno error);end;實(shí)驗(yàn)四 在pl/sql中使用游標(biāo)一.目的要求 在pl/sql中使用無(wú)參數(shù)的游標(biāo)和帶參數(shù)的游標(biāo)處理結(jié)果集 二.實(shí)驗(yàn)內(nèi)容 在pl/sql程序中使用游標(biāo)來(lái)處理結(jié)果集,分別使用fetch, while和for循環(huán)來(lái)遍歷查詢(xún)結(jié)果集中的每一條記錄,并對(duì)這些記錄進(jìn)行判斷和處理,將處理的結(jié)果格式化打印出來(lái)。使用帶參數(shù)的游標(biāo)來(lái)傳遞查詢(xún)條件,使程序更加靈活實(shí)用。 實(shí)現(xiàn)下面功能1.種不同的循環(huán)來(lái)遍歷游標(biāo)查詢(xún)結(jié)果集declare -用loop循環(huán)遍歷sc表 cu
24、rsor c1 is select sno,cno,grade from sc order by sno; v_sc sc%rowtype;begin dbms_output.put_line(rpad(學(xué)號(hào),7)|rpad(課程號(hào),6)|成績(jī)); dbms_output.put_line(rpad(=,25,=); open c1; loop fetch c1 into v_sc; exit when c1%notfound; dbms_output.put_line(v_sc.sno|v_o|v_sc.grade); end loop; dbms_output.put_line(row c
25、ount:|c1%rowcount);close c1; end;declare -用while循環(huán)遍歷sc表cursor v_sc is select * from sc; sc_rec sc%rowtype;begin open v_sc; dbms_output.put_line(學(xué)號(hào):|rpad( ,7)|課程號(hào):|rpad( ,6)|成績(jī):); fetch v_sc into sc_rec; while v_sc%found loop dbms_output.put_line(sc_rec.sno|sc_o|sc_rec.grade); fetch v_sc into sc_rec;
26、 end loop; close v_sc; end;declare cursor c1 is select sno,cno,grade from sc; -格式化輸出sc表 v_sc sc%rowtype; v_sno varchar(9);begin dbms_output.put_line(rpad(學(xué)號(hào),7)|rpad(課程號(hào),11)|成績(jī)); dbms_output.put_line(rpad(=,25,=); v_sno:=xxx; for i in c1 loop-用for循環(huán)遍歷sc表 if v_sno i.sno then dbms_output.put_line(rpad(
27、-,25,-); dbms_output.put_line(i.sno|o|i.grade); v_sno:=i.sno; else dbms_output.put_line(rpad( ,9)|o|i.grade); end if; end loop;end;2. 使用游標(biāo)實(shí)現(xiàn):將任意一門(mén)(每門(mén))課程成績(jī)高于課程平均分的學(xué)生所選的 所有課程的姓名,課程名,成績(jī)格式化輸出。declare cursor stu_grade is select student.sno,sname,cname,grade,o from student,sc sc1,course where student.sno=
28、sc1.sno and o=o and student.sno in(select sno from sc where grade(select avg(grade) from sc where o=o ) order by student.sno ; cs stu_grade%rowtype; v_sno varchar2(20):=null; cavg int:=0;begin open stu_grade; dbms_output.put_line(rpad(*,20,*)|信息查詢(xún)|rpad(*,20,*); loop fetch stu_grade into cs; exit whe
29、n stu_grade%notfound; if v_sno!=cs.sno then dbms_output.put_line(rpad(=,50,=); dbms_output.put_line(rpad( ,30, )|學(xué)號(hào):|rpad(cs.sno,10); dbms_output.put_line(rpad( ,30, )|姓名:|rpad(cs.sname,20); dbms_output.put_line(rpad( ,30, )|rpad(-,10,-); dbms_output.put_line(rpad( ,3, )|課程名:|rpad( ,10, )|成績(jī):|rpad(
30、,10, )|課程平均成績(jī):); dbms_output.put_line(rpad( ,50, ); v_sno:=cs.sno; else select avg(grade)into cavg from sc where o=o; dbms_output.put_line(rpad( ,3)|rpad(ame,10)|rpad( ,10, )|cs.grade|rpad( ,20, )|cavg); dbms_output.put_line(rpad( ,50, ); -dbms_output.put_line(rpad( ,40, )|cs.grade|rpad( ,30, )|cavg
31、); -dbms_output.put_line(cavg); -dbms_output.put_line(rpad( ,50, ); end if; end loop; dbms_output.put_line(rpad(=,50,=); exception when others then null; close stu_grade; end;實(shí)驗(yàn)五 實(shí)現(xiàn)過(guò)程,包,函數(shù)的編寫(xiě)一.目的要求 使用pl/sql語(yǔ)言編寫(xiě)過(guò)程,包和函數(shù) 二.實(shí)驗(yàn)內(nèi)容 創(chuàng)建存儲(chǔ)過(guò)程,包和函數(shù),并能通過(guò)參數(shù)將結(jié)果傳遞出去。在存儲(chǔ)過(guò)程中使用游標(biāo)處理結(jié)果集。在pl/sql塊調(diào)試編寫(xiě)的包,函數(shù)和存儲(chǔ)過(guò)程。注意包的作用,比較在
32、包體中定義的過(guò)程和函數(shù)與獨(dú)立的過(guò)程和函數(shù)有什么區(qū)別。 使用student, sc, course三張表,作存儲(chǔ)過(guò)程和函數(shù),完成下面的功能: 1.過(guò)程和函數(shù)作一存儲(chǔ)過(guò)程和函數(shù),完成下面的功能:輸入姓名,課程名,成績(jī),該過(guò)程完成對(duì)sc表的插入或修改操作,若插入成功,返回成功信息,若該選課信息已經(jīng)存在,則修改其成績(jī)?yōu)檩斎氲某煽?jī),若遇系統(tǒng)錯(cuò)誤,返回錯(cuò)誤信息。-建立存儲(chǔ)過(guò)程:create or replace procedure keke(psname student.sname%type,pcname ame%type,pgrade number)ispsno student.sno%type;pcn
33、o o%type;vc number;vs number;begin if(pgrade not between 0 and 100) then dbms_output.put_line(成績(jī)超出范圍,請(qǐng)重新輸入!); return; end if; begin select sno into psno from student where sname=psname; exception when no_data_found then vs:= 0; end; begin select cno into pcno from course where cname=pcname; exceptio
34、n when no_data_found then vc:=0; end; if vs=0 and vc=0 then dbms_output.put_line(學(xué)生:|psname|和|課程:|pcname|都不存在! 請(qǐng)重新輸入:); return; elsif vs=0 then dbms_output.put_line(學(xué)生:|psname| 不存在! 請(qǐng)重新輸入: ); return; elsif vc=0 then dbms_output.put_line(課程:|pcname| 不存在! 請(qǐng)重新輸入:); return; end if; update sc set grade=p
35、grade where sno=psno and cno=pcno; if sql%found then commit; dbms_output.put_line(修改成功!); else insert into sc values(psno,pcno,pgrade); commit; dbms_output.put_line(插入成功); end if;end;-測(cè)試1.當(dāng)學(xué)生與課程都不存在:1. 當(dāng)學(xué)生不存在:2. 當(dāng)課程不存在:3. 插入數(shù)據(jù):4. 更新數(shù)據(jù)-創(chuàng)建函數(shù)create or replace function p2(psname char, pcname char, pgrad
36、e number) return varchar is v_return varchar(200); psno varchar2(10); pcno varchar2(20); vc number;-計(jì)數(shù)器,當(dāng)課程不存在時(shí),置為0 vs number;-計(jì)數(shù)器,當(dāng)學(xué)生不存在時(shí),置為0begin-在student表中查詢(xún)輸入的學(xué)生學(xué)號(hào),如果不存在,則把vs置為0 begin select sno into psno from student where sname = psname; exception when no_data_found then vs := 0; end;-在course表
37、中查詢(xún)輸入的課程的課程號(hào),如果不存在,則把vc置為0 begin select cno into pcno from course where cname = pcname; exception when no_data_found then vc := 0; end;-只有當(dāng)vc與vs都不為0的情況,才可以插入數(shù)據(jù) if vc = 0 and vs = 0 then v_return:=警告!不存在|psname|這個(gè)學(xué)生和|pcname|這門(mén)課程,不能修改!; return v_return; elsif vc = 0 then v_return:=警告!不存在|pcname|這門(mén)課程,不
38、能修改!; return v_return; elsif vs=0 then v_return:=警告!不存在|psname|這個(gè)學(xué)生,不能修改!; return v_return; else update sc set grade = pgrade where sno = psno and cno = pcno; if sql%notfound then insert into sc values (psno, pcno, pgrade); end if; v_return:=恭喜!更新數(shù)據(jù)成功!|psno|pcname|pgrade; commit; return v_return; en
39、d if; end; end;*/2. 包練習(xí) 定義一個(gè)包,使其中包括下面 功能:1 建立過(guò)程,當(dāng)傳入學(xué)號(hào)和選課門(mén)數(shù),首先判斷sc_number表是否存在,若不存在則創(chuàng)建該表格(包括學(xué)號(hào)和選修門(mén)數(shù)兩列),將傳入值插入或修改到sc_number表中(該生不存在則插入,若存在則修改其選課門(mén)數(shù))(私有過(guò)程.2 建立過(guò)程(重載),當(dāng)用戶輸入學(xué)號(hào)(或姓名),課程號(hào),成績(jī),將該信息插入到sc表格中,若該課程已經(jīng)滿額,則提示相關(guān)信息;若該生已經(jīng)選擇了該課程,則修改該課程的成績(jī)?yōu)檩斎氤煽?jī);若該生或該課程不存在,則提示相關(guān)錯(cuò)誤。插入成功后調(diào)用上一個(gè)過(guò)程將學(xué)生選課情況修改.3 建立過(guò)程,當(dāng)用戶輸入學(xué)號(hào),將該生對(duì)應(yīng)
40、的選課信息(sc),學(xué)生基本信息(student),sc_number中關(guān)于該生的信息全部刪除,若該生不存在,則給出相關(guān)提示.4 建立過(guò)程,實(shí)現(xiàn)刪除sc_number表格的功能.包頭:create or replace package pk1is - procedure scn(psno student.sno%type,pscnt number) ; procedure insertsc(psno student.sno%type,pcno o%type,pgrade number,mess out varchar); procedure insertsc(psname student.sn
41、ame%type,pcno o%type,pgrade number,mess out varchar); procedure del(psno student.sno%type); procedure dr;end;-包體create or replace package body pk1 is-1 建立過(guò)程,當(dāng)傳入學(xué)號(hào)和選課門(mén)數(shù),首先判斷sc_number表是否存在,若不存在則創(chuàng)建該表格(包括學(xué)號(hào)和選修門(mén)數(shù)兩列)-將傳入值插入或修改到sc_number表中(該生不存在則插入,若存在則修改其選課門(mén)數(shù))(私有過(guò)程) procedure scn(psno student.sno%type,psc
42、nt number) is flag number;begin-判斷表sc_number是否存在,如果存在則將flag置為1,反之為0,不存在后建表,并將sc表中的選課門(mén)數(shù)導(dǎo)入新表中 select count(1) into flag from user_tables where table_name = upper(sc_number); if flag = 0 then execute immediate create table sc_number(sno char(10) primary key,scnt number); execute immediate insert into s
43、c_number select sno,count(*) from sc group by sno; end if; -如果傳入的學(xué)號(hào)的學(xué)生選課門(mén)數(shù)修改,如果此學(xué)生不在新表中,插入數(shù)據(jù) execute immediate update sc_number set scnt = scnt:pscnt where sno = :psno using pscnt,psno; if sql%notfound thenexecute immediate insert into sc_number values(:psno,:pscnt) using psno,pscnt;end if;commit; e
44、nd scn; -2 建立過(guò)程(重載),當(dāng)用戶輸入學(xué)號(hào)(或姓名),課程號(hào),成績(jī),將該信息插入到sc表格中,-若該課程已經(jīng)滿額,則提示相關(guān)信息;若該生已經(jīng)選擇了該課程,則修改該課程的成績(jī)?yōu)檩斎氤煽?jī);-若該生或該課程不存在,則提示相關(guān)錯(cuò)誤。插入成功后調(diào)用上一個(gè)過(guò)程將學(xué)生選課情況修改。 procedure insertsc(psno student.sno%type,pcno o%type,pgrade number,mess out varchar)is vs number; vc number;begin -在student表中查詢(xún)輸入的學(xué)生學(xué)號(hào),如果不存在,則把vs置為0 -在course表中
45、查詢(xún)輸入的課程的課程號(hào),如果不存在,則把vc置為0 select count(*) into vs from student where sno = psno; select count(*) into vc from course where cno = pcno; if vc = 0 and vs = 0 then mess := 這個(gè)學(xué)生學(xué)號(hào)和這門(mén)課程的課程號(hào)錯(cuò)誤不存在,請(qǐng)核對(duì)后再輸入; return; end if; if vs =0 then mess := 這個(gè)學(xué)生的學(xué)號(hào)錯(cuò)誤或不存在,請(qǐng)核對(duì)后在輸入; return; end if; if vc = 0 then mess :=這門(mén)
46、課程的課程號(hào)錯(cuò)誤或不存在,請(qǐng)核對(duì)后在輸入; return; end if; update sc set grade = pgrade where sno = psno and cno = pcno; mess := 修改成功; if sql%notfound then -將該門(mén)課程的已選人數(shù)和最大選課人數(shù)做比較,只是當(dāng)已選人數(shù)小于最大選課人數(shù)才可以選課 select count(*) into vs from sc where cno = psno; select maxnumber into vc from course where cno = pcno; if vs vc then ins
47、ert into sc values(psno,pcno,pgrade); mess := 選課成功; else mess :=選課人數(shù)已滿,不能選課; end if; end if; commit;end insertsc;-2 建立過(guò)程(重載),當(dāng)用戶輸入學(xué)號(hào)(或姓名),課程號(hào),成績(jī),將該信息插入到sc表格中,-若該課程已經(jīng)滿額,則提示相關(guān)信息;若該生已經(jīng)選擇了該課程,則修改該課程的成績(jī)?yōu)檩斎氤煽?jī);-若該生或該課程不存在,則提示相關(guān)錯(cuò)誤。插入成功后調(diào)用上一個(gè)過(guò)程將學(xué)生選課情況修改。procedure insertsc(psname student.sname%type,pcno o%type,pgrade number,mess out varchar)is psno student.sno%type; vs number; vc number;begin begin select sno into psno from student where sname = psname; exception when no_data_found then mess:=這個(gè)學(xué)生不存在; vs :=0; select cou
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度個(gè)人債務(wù)轉(zhuǎn)讓及債務(wù)清理執(zhí)行細(xì)則協(xié)議4篇
- 二零二五年度安全生產(chǎn)標(biāo)準(zhǔn)化建設(shè)承包合同范本3篇
- 二零二五年度吊車(chē)操作培訓(xùn)與安全規(guī)范制定合同3篇
- 二零二五年度建筑材料質(zhì)量糾紛處理合同范本6篇
- 二零二五年度城市公共廁所智能化改造合同范本2篇
- 臨時(shí)活動(dòng)用場(chǎng)地租賃合同書(shū)2024版樣本版B版
- 二零二五年度商業(yè)地產(chǎn)租賃轉(zhuǎn)供電管理合同3篇
- 2025年度教育機(jī)構(gòu)學(xué)生信息保密與隱私保護(hù)合同范本4篇
- 泰州二手房買(mǎi)賣(mài)合同2025版
- 二零二五年度高空作業(yè)樓頂廣告牌拆除與安全培訓(xùn)協(xié)議4篇
- 《醫(yī)院財(cái)務(wù)分析報(bào)告》課件
- 2025老年公寓合同管理制度
- 2024-2025學(xué)年人教版數(shù)學(xué)六年級(jí)上冊(cè) 期末綜合卷(含答案)
- 2024中國(guó)汽車(chē)后市場(chǎng)年度發(fā)展報(bào)告
- 感染性腹瀉的護(hù)理查房
- 天津市部分區(qū)2023-2024學(xué)年高二上學(xué)期期末考試 物理 含解析
- 《人工智能基礎(chǔ)》全套英語(yǔ)教學(xué)課件(共7章)
- GB/T 35613-2024綠色產(chǎn)品評(píng)價(jià)紙和紙制品
- 2022-2023學(xué)年五年級(jí)數(shù)學(xué)春季開(kāi)學(xué)摸底考(四)蘇教版
- 【螞蟻保】2024中國(guó)商業(yè)醫(yī)療險(xiǎn)發(fā)展研究藍(lán)皮書(shū)
- 康復(fù)護(hù)理練習(xí)題庫(kù)(附答案)
評(píng)論
0/150
提交評(píng)論