Compare commits
No commits in common. "9a7400d5d8b14d1170ec12e5392b81dff6eb11e7" and "ba84cdf1ccc479592fad0026ad582ec701ee1925" have entirely different histories.
9a7400d5d8
...
ba84cdf1cc
@ -1,73 +0,0 @@
|
||||
# P4 - PL/SQL block
|
||||
|
||||
**Problem Statement:**
|
||||
Write a PL/SQL block for following requirements and handle the exceptions. Roll no. of students will be entered by the user. Attendance of roll no. entered by user will be checked in the Stud table. If attendance is less than 75% then display the message “Term not granted” and set the status in stud table as “Detained”. Otherwise display message “Term granted” and set the status in stud table as “Not Detained”. Student (Roll, Name, Attendance, Status)
|
||||
|
||||
---
|
||||
|
||||
## Creating table
|
||||
|
||||
```sql
|
||||
CREATE TABLE Student(
|
||||
Roll NUMBER(14),
|
||||
Name VARCHAR(255),
|
||||
Attendance NUMBER(14),
|
||||
Status VARCHAR(255)
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
## Inserting data
|
||||
|
||||
```sql
|
||||
INSERT INTO Student VALUES (1, 'Tanmay', 76, 'Not Yet Reviewed');
|
||||
INSERT INTO Student VALUES (2, 'Rajesh', 80, 'Not Yet Reviewed');
|
||||
INSERT INTO Student VALUES (3, 'Tejas', 88, 'Not Yet Reviewed');
|
||||
INSERT INTO Student VALUES (4, 'Machkar', 35, 'Not Yet Reviewed');
|
||||
INSERT INTO Student VALUES (5, 'Jayashree', 74, 'Not Yet Reviewed');
|
||||
|
||||
```
|
||||
|
||||
## Procedure
|
||||
|
||||
```sql
|
||||
DECLARE
|
||||
p_att Student.Attendance%type;
|
||||
p_roll Student.Roll%type;
|
||||
nodata EXCEPTION;
|
||||
BEGIN
|
||||
p_roll := &p_roll;
|
||||
|
||||
IF (p_roll < 0) THEN
|
||||
raise nodata;
|
||||
END IF;
|
||||
|
||||
SELECT Attendance INTO p_att FROM Student WHERE Roll = p_roll;
|
||||
|
||||
IF (p_att < 75) THEN
|
||||
DBMS_OUTPUT.PUT_LINE('Term not granted!');
|
||||
UPDATE Student SET Status = 'Detained' WHERE Roll = p_roll;
|
||||
ELSIF (p_att >= 75) THEN
|
||||
DBMS_OUTPUT.PUT_LINE('Term granted!');
|
||||
UPDATE Student SET Status = 'Not Detained' WHERE Roll = p_roll;
|
||||
END IF;
|
||||
EXCEPTION
|
||||
WHEN nodata THEN
|
||||
DBMS_OUTPUT.PUT_LINE('Enter valid rollno!!');
|
||||
END;
|
||||
/
|
||||
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Output</summary>
|
||||
After entering every Roll no:
|
||||
ROLL NAME ATTENDANCE STATUS<br>
|
||||
1 Tanmay 76 Not Detained<br>
|
||||
2 Rajesh 80 Not Detained<br>
|
||||
3 Tejas 88 Not Detained<br>
|
||||
4 Machkar 35 Detained<br>
|
||||
5 Jayashree 74 Detained<br>
|
||||
</details>
|
||||
|
||||
---
|
@ -1,6 +1,8 @@
|
||||
# P9 - Trigger
|
||||
|
||||
**Problem Statement:** Trigger: Create a row level trigger for the CUSTOMERS table that would fire INSERT or UPDATE or DELETE operations performed on the CUSTOMERS table. This trigger will display the salary difference between the old values and new values.
|
||||
**Problem Statement:**
|
||||
|
||||
Trigger: Create a row level trigger for the CUSTOMERS table that would fire INSERT or UPDATE or DELETE operations performed on the CUSTOMERS table. This trigger will display the salary difference between the old values and new values.
|
||||
|
||||
---
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user