0% found this document useful (0 votes)
2 views

naina dbms 4

The document outlines an experiment in a Computer Science course focused on database management systems (DBMS) using PL/SQL. It includes tasks such as writing a PL/SQL block with explicit cursors, creating SQL views, and implementing stored procedures for modifying records. The learning outcomes emphasize understanding PL/SQL constructs, data filtering, and procedural logic.

Uploaded by

Aditya 18--
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

naina dbms 4

The document outlines an experiment in a Computer Science course focused on database management systems (DBMS) using PL/SQL. It includes tasks such as writing a PL/SQL block with explicit cursors, creating SQL views, and implementing stored procedures for modifying records. The learning outcomes emphasize understanding PL/SQL constructs, data filtering, and procedural logic.

Uploaded by

Aditya 18--
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

EXPERIMENT: 1.4

Name: Naina Dhankar UID: 23BET10139


Branch : B.E-IT Section/Group: 818/B
Semester : 4 Date of Performance: 11/04/25
Subject : DBMS Subject Code : 23ITH-205

AIM: Q1: A hospital manages patient details:

PatientID Name Age BillAmount


101 Ananya 32 5000
102 Rohan 45 8000
103 Sunil 28 3000

 Write a PL/SQL block using an explicit cursor to display patients with


a bill amount greater than 4000.

Objectives :

1. To write a PL/SQL block using explicit cursors


for conditional data display.

2. To create a SQL view (TopStudents_View) for students


scoring above 80.

3. To implement a stored procedure (IncreaseMarks) that


modifies multiple records.

4. To enhance database programming skills using PL/SQL constructs.

5. To practice data filtering, view management,


and procedural logic in Oracle.

CODE :

CREATE TABLE Patients (


PatientID NUMBER PRIMARY KEY,
Name VARCHAR2(50),
Age NUMBER,
BillAmount NUMBER
);
INSERT INTO Patients VALUES (101, 'Ananya', 32, 5000);
INSERT INTO Patients VALUES (102, 'Rohan', 45, 8000);
INSERT INTO Patients VALUES (103, 'Sunil', 28, 3000);

COMMIT;
SET SERVEROUTPUT ON;

DECLARE
CURSOR patient_cursor IS
SELECT PatientID, Name, Age, BillAmount FROM Patients
WHERE BillAmount > 4000;

v_PatientID NUMBER; v_Name VARCHAR2(50);


v_Age NUMBER;
v_BillAmount NUMBER;
BEGIN
OPEN patient_cursor;
LOOP
FETCH patient_cursor INTO v_PatientID, v_Name, v_Age, v_BillAmount;
EXIT WHEN patient_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('PatientID: ' || v_PatientID ||
', Name: ' || v_Name ||
', Age: ' || v_Age ||
', BillAmount: ' || v_BillAmount);
END LOOP;
CLOSE patient_cursor;
END;

OUTPUT:
Q2: A company manages employee salary details:

EmpID Name Salary


E101 Raj 50000
E102 Meera 30000
E103 Sunil 70000

 Create a view HighSalary_View to display employees with a


salary greater than 40000.

CODE :
CREATE TABLE Employee

( EmpID VARCHAR2(10),

Name VARCHAR2(50),

Salary NUMBER

);

INSERT INTO Employee VALUES ('E101', 'Raj', 50000);

INSERT INTO Employee VALUES ('E102', 'Meera', 30000);

INSERT INTO Employee VALUES ('E103', 'Sunil', 70000);

COMMIT;

CREATE VIEW HighSalary_View

AS SELECT EmpID, Name, Salary

FROM Employee

WHERE Salary > 40000;

SELECT * FROM HighSalary_View;

OUTPUT:
Q3: Create a procedure IncreaseSalary to increase the salary of "Meera" by 5000.

CODE :

CREATE TABLE Employee


( EmpID VARCHAR2(10),
Name VARCHAR2(50),
Salary NUMBER
);
INSERT INTO Employee VALUES ('E101', 'Raj', 50000);
INSERT INTO Employee VALUES ('E102', 'Meera', 30000);
INSERT INTO Employee VALUES ('E103', 'Sunil', 70000);
CREATE VIEW HighSalary_View
AS SELECT EmpID, Name, Salary
FROM Employee
WHERE Salary > 40000;
SELECT * FROM HighSalary_View;
CREATE OR REPLACE PROCEDURE IncreaseSalary IS
BEGIN
UPDATE Employee
SET Salary = Salary + 5000
WHERE Name = 'Meera';

COMMIT;
END;

OUTPUT:
Learning Outcomes:

1. Understand the use of explicit cursors in PL/SQL to handle


query result sets.
2. Learn to create and apply SQL views to filter and present
specific data.
3. Gain practical experience in writing procedures to perform
batch updates.
4. Develop skills in conditionally retrieving and displaying
database records.
5. Strengthen overall understanding of PL/SQL block structure
and syntax.

You might also like