Beruflich Dokumente
Kultur Dokumente
SESSION create table ssn(sno number(2) primary key, obsmarks number(2), recmarks number(2), viva number(2), booksub char(3));
PROJECT create table project(pno number(2) primary key, overallmarks number(2), layoutmarks number(2));
STUDENT create table stdent(rollno number(2) primary key, fname varchar(30), minit char(1), lname varchar(30),gender char(1), year number(4), batch char(2), pno number(2), foreign key(pno) references project(pno));
TESTSANDEXAMS create table tests_exams(testid number(2), theoryex number(2), pracex number(2), rollno number(2), primary key(testid,rollno), foreign key(rollno) references stdent(rollno));
ATTENDED create table attended(sno number(2), rollno number(2), primary key(sno,rollno), foreign key(sno) references ssn(sno), foreign key(rollno) references stdent(rollno));
GOT create table got( rollno number(2) primary key, t_total number(3), s_total number(3), foreign key(rollno) references stdent(rollno));
MARKS create table marks( rollno number(2) primary key, grade char(1), finalmarks number(2),foreign key(rollno) references stdent(rollno));
SESSION TABLE-ssn
ATTENDED TABLE-attended
GOT TABLE-got
MARKS TABLE-marks
insert into tests_exams values(1,10,11,5); insert into tests_exams values(2,22,22,5); insert into tests_exams values(1,21,14,6); insert into tests_exams values(2,25,25,6); ATTENDED insert into attended values(1,1); insert into attended values(1,2); insert into attended values(1,3); insert into attended values(1,4); insert into attended values(1,5); insert into attended values(1,6); insert into attended values(2,1); insert into attended values(2,2); insert into attended values(2,3); insert into attended values(2,4); insert into attended values(3,2); insert into attended values(3,4); insert into attended values(3,5); insert into attended values(3,6); insert into attended values(3,1); insert into attended values(4,6); insert into attended values(4,5); insert into attended values(4,4); insert into attended values(4,3); insert into attended values(4,2); insert into attended values(5,2); insert into attended values(5,3); insert into attended values(5,4);
FUNCTION TO FIND OUT T_TOTAL IN GOT TABLE create or replace function add_t(roll in stdent.rollno%type) return number is a number; b number; c number; cursor c1 is select avg(theoryex) from tests_exams where rollno=roll; cursor c2 is select avg(pracex) from tests_exams where rollno=roll; begin open c1; open c2; fetch c1 into a; fetch c2 into b; c:=a+b; close c1; close c2; return c; end; / FUNCTION TO FIND OUT S_TOTAL IN GOT TABLE create or replace function add_s(roll in stdent.rollno%type) return number is a number; b number; c number; d number;
cursor c1 is select avg(obsmarks) from ssn,attended where attended.sno=ssn.sno and rollno=roll; cursor c2 is select avg(recmarks) from ssn,attended where attended.sno=ssn.sno and rollno=roll; cursor c3 is select avg(viva) from ssn,attended where attended.sno=ssn.sno and rollno=roll; begin open c1; open c2; open c3; fetch c1 into a; fetch c2 into b; fetch c3 into d; c:=a+b+d; close c1; close c2; close c3; return c; end; / GOT insert into got values(1,add_t(1),add_s(1)); insert into got values(2,add_t(2),add_s(2)); insert into got values(3,add_t(3),add_s(3)); insert into got values(4,add_t(4),add_s(4)); insert into got values(5,add_t(5),add_s(5)); insert into got values(6,add_t(6),add_s(6)); update project set overallmarks =overallmarks+5;
FUNCTION TO GET FINAL MARKS IN MARKS TABLE create or replace function get_marks(roll in stdent.rollno%type) return number is a number; b number; c number; d number; e number; cursor c1 is select t_total from got where rollno=roll; cursor c2 is select s_total from got where rollno=roll; cursor c3 is select overallmarks from project,stdent where project.pno=stdent.pno and rollno=roll; cursor c4 is select layoutmarks from project,stdent where project.pno=stdent.pno and rollno=roll; begin open c1; open c2; open c3; open c4; fetch c1 into a; fetch c2 into b; fetch c3 into c; fetch c4 into d; e:=(a+b+c+d)/2; close c1; close c2; close c3; close c4; return e;
end; /
FUNCTION TO GET FINAL GRADES IN GOT TABLE create or replace function get_grade(roll in stdent.rollno%type) return char is a number; b number; c number; d number; e number; f char; cursor c1 is select t_total from got where rollno=roll; cursor c2 is select s_total from got where rollno=roll; cursor c3 is select overallmarks from project,stdent where project.pno=stdent.pno and rollno=roll; cursor c4 is select layoutmarks from project,stdent where project.pno=stdent.pno and rollno=roll; begin open c1; open c2; open c3; open c4; fetch c1 into a; fetch c2 into b; fetch c3 into c; fetch c4 into d; e:=(a+b+c+d)/2; close c1;
close c2; close c3; close c4; if e>45 then f:='S'; elsif e>40 then f:='A'; elsif e>35 then f:='B'; elsif e>30 then f:='C'; elsif e>25 then f:='D'; else f:='F'; end if; return f; end; / MARKS insert into marks values(1,get_grade(1),get_marks(1)); insert into marks values(2,get_grade(2),get_marks(2)); insert into marks values(3,get_grade(3),get_marks(3)); insert into marks values(4,get_grade(4),get_marks(4)); insert into marks values(5,get_grade(5),get_marks(5)); insert into marks values(6,get_grade(6),get_marks(6));
SSN TABLE
TESTS_EXAMS
ATTENDED
GOT
MARKS
PROJECT