ASSIGNMENT NO : 7
CREATE TABLE student(
rollno NUMBER PRIMARY KEY,
name varchar2(100),
percentage NUMBER,
status VARCHAR(30)
);
INSERT INTO (rollno, name, percentage)VALUES(1,'Sandip Rajput',85);
INSERT INTO (rollno, name, percentage)VALUES(2,'Rohit Lande',75);
INSERT INTO (rollno, name, percentage)VALUES(3,'Meghraj Sonawane',72);
INSERT INTO (rollno, name, percentage)VALUES(4,'Suyash Sonje',45);
INSERT INTO (rollno, name, percentage)VALUES(5,'Suyog Pagar',55);
INSERT INTO (rollno, name, percentage)VALUES(6,'Avinash Bharude',65);
INSERT INTO (rollno, name, percentage)VALUES(7,'Tushar Jadhav',35);
DECLARE
v_rollno NUMBER;
v_attendance NUMBER;
BEGIN
-- Accept roll number from user
v_rollno := :Enter_Roll_Number;
-- Retrieve attendance for the student
SELECT attendance INTO v_attendance
FROM Student
WHERE rollno = v_rollno;
-- Check attendance and update status
IF v_attendance < 75 THEN
DBMS_OUTPUT.PUT_LINE('Term not granted.');
UPDATE Student
SET status = 'D'
WHERE rollno = v_rollno;
COMMIT;
ELSE
DBMS_OUTPUT.PUT_LINE('Term granted.');
UPDATE Student
SET status = 'ND'
WHERE rollno = v_rollno;
COMMIT;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No student found with the given roll number.');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An unexpected error occurred: ' || SQLERRM);
END;