0% found this document useful (0 votes)
10 views2 pages

Program 7

The document outlines the creation of a 'student' table in a database with fields for roll number, name, percentage, and status. It includes SQL commands to insert student records and a PL/SQL block to check attendance and update the student's status based on their attendance percentage. Error handling is also implemented to manage cases where no student is found or unexpected errors occur.

Uploaded by

Rohit Lande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Program 7

The document outlines the creation of a 'student' table in a database with fields for roll number, name, percentage, and status. It includes SQL commands to insert student records and a PL/SQL block to check attendance and update the student's status based on their attendance percentage. Error handling is also implemented to manage cases where no student is found or unexpected errors occur.

Uploaded by

Rohit Lande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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;

You might also like