0% found this document useful (0 votes)
5 views28 pages

DBMS Lab Manual

The document is a lab manual for a Database Management Systems course at Mohanbabu University, detailing exercises for students to design and analyze an ER model for a Library Management System. It includes instructions for implementing various SQL commands, integrity constraints, PL/SQL programming, and database operations such as joins and triggers. The manual aims to provide hands-on experience in database design and management through practical exercises.

Uploaded by

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

DBMS Lab Manual

The document is a lab manual for a Database Management Systems course at Mohanbabu University, detailing exercises for students to design and analyze an ER model for a Library Management System. It includes instructions for implementing various SQL commands, integrity constraints, PL/SQL programming, and database operations such as joins and triggers. The manual aims to provide hands-on experience in database design and management through practical exercises.

Uploaded by

ravi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 28

MOHANBABU UNIVERSITY

Sree Sainath Nagar, Tirupati 517102

Department Of Data Science

LAB MANUAL

IV Semester

22CS102005: Database Management Systems

Prepared by
Course Code Course Title L T P S C

22CS102005 DATABASE MANAGEMENT SYSTEMS 3 - 2 - 4

EXPERIENTIAL LEARNING

LIST OF EXERCISES:
1.Design and analyze an ER Model for the following use case.
The Library Management System database keeps track of readers with the
following considerations –
• The system keeps track of the staff with a single point
authentication system comprising login Id and password.
• Staff maintains the book catalog with its ISBN, Book title, price
(in INR), category (novel, general, story), edition, author Number and details.
• A publisher has publisher Id, Year when the book was published,
and name of the book.
• Readers are registered with their user_id, email, name (first
name, last name), Phone no (multiple entries allowed), communication
address. The staff keeps track of readers.
Choose appropriate Entities and attributes and relationships and draw the
complete ER diagram.
2.a) Implement Data Definition Language commands -Create, Alter, Drop,
Truncate and Rename.
b). Implement Data Manipulation Language commands - Insert, Select,
Update, and Delete.
c) Implement Single Row functions - Character, Numeric and Date functions.

3.Implement various types of integrity constraints - NOT NULL constraint,


DEFAULT constraint, UNIQUE constraint, PRIMARY key, FOREIGN key, CHECK
constraint.

4.a) Implement group functions with different operators such as aggregate


operators, group by, having and order by.
b) Implement nested and correlated nested queries using set operators and
set comparison operators.

5. a) Creation of views, synonyms, sequence, indexes and save point.


b) Implement various types of joins - outer join and inner join.

Basic PL/SQL:
6. Construct PL/SQL block for the following:
a. To determine whether a number is palindrome
b. To determine whether a number is an Armstrong number
c. To find greatest of three numbers
d. To display Fibonacci series

Control Structures:
7.a) Write a program in PL/SQL to update the salary of a specific employee
by 20% if the salary less than 30000/- and 10% when the salary in between
30000/- and 60000/- and 5% when the salary is above 60000/- and display
the salary with a suitable message.
b) Write a PL/SQL program to display the description of the grade against a
student’s grade using CASE statement.

Exception Handling:
8. a) Develop a PL/SQL program that displays the name and address of a
student whose ID is given. If there is no student with the given student ID in
the database, the program should raise a run-time exception
NO_DATA_FOUND, which should be captured in the EXCEPTION block.
b). Construct the user-defined exceptions to get the salary of an employee
and check it with the job’s salary range. If the salary is below the range,
raise an exception BELOW_SALARY_RANGE. If the salary is above the range,
raise the exception ABOVE_SALARY_RANGE.

Functions:
9.a) Write a function that accepts two numbers A and B and performs the
following operations.
1. Addition
2. Subtraction
3. Multiplication
4. Division

b) Write a PL/SQL block that reverses the given number.

Procedures:
10. a) Write a procedure that accepts two numbers and displays their sum.
b) Write procedures to demonstrate IN, IN OUT and OUT parameters.

Cursors:
11.a) Write a block in PL/SQL to create a Cursor that displays the employee
name and
number of jobs he or she has done in the past.
b) Write a program in PL/SQL to create a cursor to display the name and
salary of
each employee in the EMPLOYEES table whose salary is less than that
specified
by a passed-in parameter value.

Triggers:
12. Develop a suitable employee database application by considering
appropriate attributes.
a) Whenever the inserted or updated salary is more than 10 lacs per month a
trigger should be fired.

b) Whenever, the inserted or updated salary is less than 5000 per month a
trigger should be activated.
1. Design and analyze an ER Model for the following use case.
The Library Management System database keeps track of readers with the
following considerations –
• The system keeps track of the staff with a single point
authentication system comprising login Id and password.
• Staff maintains the book catalog with its ISBN, Book title, price
(in INR), category (novel, general, story), edition, author Number and details.
• A publisher has publisher Id, Year when the book was published,
and name of the book.
• Readers are registered with their user_id, email, name (first
name, last name), Phone no (multiple entries allowed), communication
address. The staff keeps track of readers.
Choose appropriate Entities and attributes and relationships and draw the
complete ER diagram.

Entities and Attributes

Based on the use case, the following entities and their attributes are
identified:

1. Staff
o StaffID (Primary Key)

o Name

o LoginID (Unique)

o Password

2. Book

o ISBN (Primary Key)

o Title

o Price

o Category (e.g., Novel, General, Story)

o Edition

o AuthorID (Foreign Key, linked to Author)

o PublisherID (Foreign Key, linked to Publisher)

3. Author

o AuthorID (Primary Key)


o Name

o Biography

4. Publisher

o PublisherID (Primary Key)

o Name

o YearPublished

5. Reader

o ReaderID (Primary Key)

o Email

o FirstName

o LastName

o CommunicationAddress

o PhoneNo (Allows multiple entries)

6. Catalog

o CatalogID (Primary Key)

o StaffID (Foreign Key, linked to Staff)

o ISBN (Foreign Key, linked to Book)

o DateAdded

Relationships

1. Staff maintains Catalog


o Relationship: "Maintains"

o Cardinality: One Staff can maintain multiple catalog entries; each


catalog entry is maintained by one staff member.

2. Book has Author

o Relationship: "Written By"

o Cardinality: One Book can have multiple Authors; each Author


can write multiple Books (Many-to-Many).

3. Book has Publisher


o Relationship: "Published By"

o Cardinality: One Book is published by one Publisher; each


Publisher can publish multiple Books (One-to-Many).

4. Staff tracks Reader

o Relationship: "Tracks"

o Cardinality: One Staff can track multiple Readers; each Reader is


tracked by one Staff member (One-to-Many).

5. Reader has Phone Numbers

o Relationship: "Has"

o Cardinality: One Reader can have multiple Phone Numbers.

ER Diagram

The ER diagram would include:

 Entities with their respective attributes represented in ellipses.


 Relationships represented as diamonds connecting entities.

 Primary keys underlined.

 Foreign keys explicitly mentioned with their relationships.


2. a) Implement Data Definition Language commands -Create, Alter,
Drop, Truncate and Rename.
b). Implement Data Manipulation Language commands - Insert,
Select, Update, and Delete.
c) Implement Single Row functions - Character, Numeric and Date
functions.

a) Data Definition Language (DDL) Commands

Create Table
CREATE TABLE Books (
ISBN VARCHAR(13) PRIMARY KEY,
Title VARCHAR(100),
Price DECIMAL(10, 2),
Category VARCHAR(20),
Edition INT
);
Alter Table
ALTER TABLE Books ADD AuthorID INT;

Drop Table
DROP TABLE Books;

Truncate Table
TRUNCATE TABLE Books;

Rename Table
RENAME TABLE Books TO LibraryBooks;

b) Data Manipulation Language (DML) Commands


Insert Data
INSERT INTO Books (ISBN, Title, Price, Category, Edition)
VALUES ('9781234567890', 'Learning SQL', 500.00, 'Education', 1);

Select Data
SELECT * FROM Books WHERE Category = 'Education';

Update Data
UPDATE Books
SET Price = 550.00
WHERE ISBN = '9781234567890';
Delete Data
DELETE FROM Books WHERE ISBN = '9781234567890';

c) Single Row Functions


Character Functions
SELECT UPPER(Title) AS UpperCaseTitle, LOWER(Title) AS LowerCaseTitle
FROM Books;

Numeric Functions
SELECT ROUND(Price, 1) AS RoundedPrice, CEIL(Price) AS CeilingPrice,
FLOOR(Price) AS FloorPrice
FROM Books;

Date Functions
SELECT CURRENT_DATE AS Today,
DATE_ADD(CURRENT_DATE, INTERVAL 7 DAY) AS OneWeekLater,
DATE_FORMAT(CURRENT_DATE, '%Y-%m-%d') AS FormattedDate;
3. Implement various types of integrity constraints - NOT NULL
constraint, DEFAULT constraint, UNIQUE constraint, PRIMARY key,
FOREIGN key, CHECK constraint.

Creating a Table with Constraints

CREATE TABLE Books (


ISBN VARCHAR(13) PRIMARY KEY,
Title VARCHAR(100) NOT NULL,
Price DECIMAL(10, 2) CHECK (Price > 0),
Category VARCHAR(20) DEFAULT 'General',
Edition INT,
PublisherID INT,
UNIQUE (Title),
FOREIGN KEY (PublisherID) REFERENCES Publishers(PublisherID)
);

Explanation of Constraints
1. NOT NULL
o Ensures that a column cannot have a NULL value.
o Example: Title must always have a value.
2. DEFAULT
o Provides a default value if no value is specified during insertion.
o Example: Category will default to 'General' if no value is
provided.
3. UNIQUE
o Ensures that all values in a column are unique.
o Example: Title must be unique for each row.
4. PRIMARY KEY
o Combines the properties of NOT NULL and UNIQUE. Each table
must have one primary key.
o Example: ISBN is a unique identifier for each book.
5. FOREIGN KEY
o Enforces a relationship between columns in two tables.
o Example: PublisherID in the Books table references the
PublisherID column in the Publishers table.
6. CHECK
o Ensures that all values in a column satisfy a specific condition.
o Example: Price must always be greater than 0.
o
4.a) Implement group functions with different operators such as
aggregate operators, group by, having and order by.
b) Implement nested and correlated nested queries using set
operators and set comparison operators.

a) Implement Group Functions


1. Aggregate Operators
Aggregate functions include SUM, AVG, MIN, MAX, and COUNT.
SELECT Category, COUNT(*) AS TotalBooks, AVG(Price) AS AveragePrice
FROM Books
GROUP BY Category;

2. Group By
Groups the data by a specific column to perform aggregate functions.
SELECT PublisherID, SUM(Price) AS TotalPrice
FROM Books
GROUP BY PublisherID;

3. Having
Filters groups based on aggregate results.
SELECT PublisherID, COUNT(*) AS TotalBooks
FROM Books
GROUP BY PublisherID
HAVING COUNT(*) > 5; -- Only publishers with more than 5 books

4. Order By
Orders the results of a query.
SELECT Category, COUNT(*) AS TotalBooks
FROM Books
GROUP BY Category
ORDER BY TotalBooks DESC; -- Orders by the total number of books in
descending order

b) Implement Nested and Correlated Nested Queries


1. Nested Queries
A subquery that is executed once for the main query.
Using Set Operators:
SELECT Title
FROM Books
WHERE Price > (SELECT AVG(Price) FROM Books);
Using Set Comparison Operators:
SELECT Title
FROM Books
WHERE PublisherID IN (SELECT PublisherID FROM Publishers WHERE Name =
'Pearson');

2. Correlated Nested Queries


A subquery that depends on the outer query for its execution.
SELECT Title, Price
FROM Books b1
WHERE Price > (SELECT AVG(Price) FROM Books b2 WHERE b1.PublisherID =
b2.PublisherID);

3. Using Set Operators


Combine results from multiple queries using operators like UNION,
INTERSECT, and EXCEPT.

Union Example:
SELECT Title FROM Books WHERE Category = 'Novel'
UNION
SELECT Title FROM Books WHERE Price > 500;

Intersect Example:
SELECT Title FROM Books WHERE Category = 'Story'
INTERSECT
SELECT Title FROM Books WHERE PublisherID = 1;

Except Example:
SELECT Title FROM Books WHERE Category = 'General'
EXCEPT
SELECT Title FROM Books WHERE Price < 300;
5. a) Creation of views, synonyms, sequence, indexes and save
point.
b) Implement various types of joins - outer join and inner join.

a) Creation of Views, Synonyms, Sequence, Indexes, and Savepoint


1. Create a View
CREATE VIEW BookDetails AS
SELECT b.ISBN, b.Title, b.Price, p.Name AS PublisherName
FROM Books b
JOIN Publishers p ON b.PublisherID = p.PublisherID;
Use Case: A view to show book details along with publisher information.

2. Create a Synonym
CREATE SYNONYM PubBooks FOR Books;
Use Case: Create an alternate name (PubBooks) for the Books table.

3. Create a Sequence
CREATE SEQUENCE BookSeq
START WITH 1
INCREMENT BY 1;
Use Case: A sequence to generate unique IDs for new books.

4. Create an Index
CREATE INDEX idx_book_category ON Books (Category);
Use Case: Create an index on the Category column to speed up searches.

5. Savepoint
BEGIN;
INSERT INTO Books (ISBN, Title, Price, Category, Edition, PublisherID)
VALUES ('9786666666666', 'SQL Guide', 400.00, 'Education', 2, 1);

SAVEPOINT BeforeDelete;

DELETE FROM Books WHERE ISBN = '9786666666666';

ROLLBACK TO BeforeDelete; -- Restores the state to before the delete


COMMIT;

b) Implement Various Types of Joins


1. Inner Join
SELECT b.ISBN, b.Title, p.Name AS PublisherName
FROM Books b
INNER JOIN Publishers p ON b.PublisherID = p.PublisherID;
Use Case: Fetch books along with their publishers. Only rows with matching
PublisherID in both tables are included.

2. Left Outer Join


SELECT b.ISBN, b.Title, p.Name AS PublisherName
FROM Books b
LEFT OUTER JOIN Publishers p ON b.PublisherID = p.PublisherID;
Use Case: Fetch all books along with their publishers. Books without
publishers will have NULL for the publisher's details.

3. Right Outer Join


SELECT b.ISBN, b.Title, p.Name AS PublisherName
FROM Books b
RIGHT OUTER JOIN Publishers p ON b.PublisherID = p.PublisherID;
Use Case: Fetch all publishers along with their books. Publishers without
books will have NULL for the book details.

4. Full Outer Join


SELECT b.ISBN, b.Title, p.Name AS PublisherName
FROM Books b
FULL OUTER JOIN Publishers p ON b.PublisherID = p.PublisherID;
Use Case: Fetch all books and all publishers. Non-matching rows will have
NULL for missing values.

5. Cross Join
SELECT b.Title, p.Name AS PublisherName
FROM Books b
CROSS JOIN Publishers p;
Use Case: Create a Cartesian product of books and publishers. Each book is
paired with every publisher.
Basic PL/SQL:
6. Construct PL/SQL block for the following:
a. To determine whether a number is palindrome
b. To determine whether a number is an Armstrong number
c. To find greatest of three numbers
d. To display Fibonacci series

a) To Determine Whether a Number is a Palindrome


DECLARE
num NUMBER := 121;
reverse_num NUMBER := 0;
temp_num NUMBER := num;
remainder NUMBER;
BEGIN
WHILE temp_num > 0 LOOP
remainder := MOD(temp_num, 10);
reverse_num := reverse_num * 10 + remainder;
temp_num := FLOOR(temp_num / 10);
END LOOP;

IF reverse_num = num THEN


DBMS_OUTPUT.PUT_LINE(num || ' is a Palindrome.');
ELSE
DBMS_OUTPUT.PUT_LINE(num || ' is not a Palindrome.');
END IF;
END;

b) To Determine Whether a Number is an Armstrong Number


DECLARE
num NUMBER := 153;
temp_num NUMBER := num;
sum NUMBER := 0;
remainder NUMBER;
BEGIN
WHILE temp_num > 0 LOOP
remainder := MOD(temp_num, 10);
sum := sum + POWER(remainder, 3);
temp_num := FLOOR(temp_num / 10);
END LOOP;

IF sum = num THEN


DBMS_OUTPUT.PUT_LINE(num || ' is an Armstrong Number.');
ELSE
DBMS_OUTPUT.PUT_LINE(num || ' is not an Armstrong Number.');
END IF;
END;

c) To Find the Greatest of Three Numbers


DECLARE
num1 NUMBER := 12;
num2 NUMBER := 15;
num3 NUMBER := 9;
greatest NUMBER;
BEGIN
IF num1 > num2 AND num1 > num3 THEN
greatest := num1;
ELSIF num2 > num1 AND num2 > num3 THEN
greatest := num2;
ELSE
greatest := num3;
END IF;

DBMS_OUTPUT.PUT_LINE('The greatest number is: ' || greatest);


END;

d) To Display Fibonacci Series


sql
Copy code
DECLARE
n NUMBER := 10;
first NUMBER := 0;
second NUMBER := 1;
next NUMBER;
i NUMBER := 1;
BEGIN
DBMS_OUTPUT.PUT_LINE('Fibonacci Series:');
DBMS_OUTPUT.PUT_LINE(first);
DBMS_OUTPUT.PUT_LINE(second);

WHILE i <= n - 2 LOOP


next := first + second;
DBMS_OUTPUT.PUT_LINE(next);
first := second;
second := next;
i := i + 1;
END LOOP;
END;
Control Structures:
7.a) Write a program in PL/SQL to update the salary of a specific
employee by 20% if the salary less than 30000/- and 10% when the
salary in between 30000/- and 60000/- and 5% when the salary is
above 60000/- and display the salary with a suitable message.
b) Write a PL/SQL program to display the description of the grade
against a student’s grade using CASE statement.

a) PL/SQL Program to Update Employee Salary


DECLARE
emp_id NUMBER := 101;
current_salary NUMBER;
updated_salary NUMBER;
BEGIN
-- Fetch the current salary of the employee
SELECT salary INTO current_salary FROM employees WHERE employee_id
= emp_id;

-- Determine the percentage increase based on the current salary


IF current_salary < 30000 THEN
updated_salary := current_salary * 1.2;
ELSIF current_salary BETWEEN 30000 AND 60000 THEN
updated_salary := current_salary * 1.1;
ELSE
updated_salary := current_salary * 1.05;
END IF;

-- Update the employee's salary in the database


UPDATE employees
SET salary = updated_salary
WHERE employee_id = emp_id;

-- Display a suitable message with the updated salary


DBMS_OUTPUT.PUT_LINE('Employee ID: ' || emp_id || ' - Salary updated to:
' || updated_salary);
END;

7.b) PL/SQL Program to Display Grade Description Using CASE


Statement
DECLARE
student_grade CHAR(1) := 'A';
grade_description VARCHAR2(50);
BEGIN
-- Determine the description of the grade using CASE
grade_description := CASE
WHEN student_grade = 'A' THEN 'Excellent'
WHEN student_grade = 'B' THEN 'Good'
WHEN student_grade = 'C' THEN 'Average'
WHEN student_grade = 'D' THEN 'Below Average'
WHEN student_grade = 'F' THEN 'Fail'
ELSE 'Invalid Grade'
END;

-- Display the grade description


DBMS_OUTPUT.PUT_LINE('Grade: ' || student_grade || ' - Description: ' ||
grade_description);
END;
Exception Handling:
8. a) Develop a PL/SQL program that displays the name and address
of a student whose ID is given. If there is no student with the given
student ID in the database, the program should raise a run-time
exception NO_DATA_FOUND, which should be captured in the
EXCEPTION block.
b). Construct the user-defined exceptions to get the salary of an
employee and check it with the job’s salary range. If the salary is
below the range, raise an exception BELOW_SALARY_RANGE. If the
salary is above the range, raise the exception
ABOVE_SALARY_RANGE.

Example 1:
DECLARE
name varchar(10);
id number(5);
BEGIN
SELECT sname, sid
INTO name, id
FROM sailors
WHERE sid = 101;
DBMS_OUTPUT.PUT_LINE ('Name: '||name);
DBMS_OUTPUT.PUT_LINE ('ID: ' ||id);
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('No such customer!');
WHEN others THEN
dbms_output.put_line('Error!');
END;
/

Example 2:
declare
name varchar(10);
age number(3);
begin
select sname, age
into name, age
from sailors
where sid=101;
dbms_output.put_line('Sailor Name: '||name||chr(9)||'Age: '||age);
exception
when no_data_found then
dbms_output.put_line('No such sailors id available in the database');
when others then
dbms_output.put_line('Error.....!');
end;
/

Example 3:
declare
x number(5):=&x;
y number(5):=&y;
div number(5);
exp1 exception;
exp2 exception;
begin
if y=0 then
raise exp1;
else if y>x then
raise exp2;
else
div:=x/y;
dbms_output.put_line('Result: '||div);
end if;
end if;
exception
when exp1 then
dbms_output.put_line('Error...!');
dbms_output.put_line('Divison by zero is not allowed');
when exp2 then
dbms_output.put_line('Error...!');
dbms_output.put_line('Y is greater than X, please check the values');
end;
/
Functions:
9.a) Write a function that accepts two numbers A and B and
performs the following operations.
1. Addition
2. Subtraction
3. Multiplication
4. Division

b) Write a PL/SQL block that reverses the given number.

a) Write a function that accepts two numbers A and B and performs


the following operations.
create or replace function fun1(a number, b number, op varchar) return
number
as
begin
if op='+' then
return (a+b);
else if op='-' then
return (a-b);
else if op='*' then
return (a*b);
else
return (a/b);
end if;
end if;
end if;
end;

b) Write a PL/SQL block that reverses the given number.


declare
n int:=&n;
m int;
k int;
rev int:=0;
begin
m:=n;
while n>0
loop
k:=mod(n,10);
rev:=rev*10+k;
n:=n/10;
end loop;
if m=rev then
dbms_output.put_line(m||' is palindrome');
else
dbms_output.put_line(m||' is not a palindrome');
end if;
end;
/
Procedures:
10. a) Write a procedure that accepts two numbers and displays
their sum.
b) Write procedures to demonstrate IN, IN OUT and OUT
parameters.

create or replace procedure


adjust_sal(id IN empsal.eid%type, amt IN empsal.esal%type)
AS
begin
update empsal
set esal=esal+amt
where eid=id;
end;
/

declare
a int;
b int;
c int;
procedure find_min(x in int, y in int, z out int)
is
begin
if x>y then z:=x;
else z:=y;
end if;
end;
begin
a:=&a;
b:=&b;
find_min(a,b,c);
dbms_output.put_line('Minimum of '||a||' and '||b||' is '||c);
end;
/
Cursors:
11.a) Write a block in PL/SQL to create a Cursor that displays the
employee’s name and
number of jobs he or she has done in the past.
b) Write a program in PL/SQL to create a cursor to display the name
and salary of
each employee in the EMPLOYEES table whose salary is less than
that specified
by a passed-in parameter value.

DECLARE
total number(2);
BEGIN
UPDATE empsal
SET esal = esal - 500;
IF sql%notfound THEN
dbms_output.put_line('no customers selected');
ELSIF sql%found THEN
total := sql%rowcount;
dbms_output.put_line( total || ' customers selected ');
END IF;
END;
/

declare
id empsal.eid%type;
total number;
begin
id:=&eid;
delete from empsal where eid=id;
if sql%found then
total:=sql%rowcount;
dbms_output.put_line(total||' record deleted');
else
dbms_output.put_line('Record not found');
end if;
commit;
end;
/

declare
cursor c1 is select sid,sname,age from sailors;
--id sailors.sid%type;
--name sailors.sname%type;
--age sailors.age%type;
vchar c1%rowtype;
begin
open c1;
dbms_output.put_line('ID'||chr(9)||'NAME'||chr(9)||'AGE');
dbms_output.put_line('--'||chr(9)||'----'||chr(9)||'---');
loop
fetch c1 into vchar;
exit when c1%notfound;
dbms_output.put_line(vchar.sid||chr(9)||vchar.sname||chr(9)||
vchar.age);
end loop;
close c1;
end;
/
Triggers:
12. Develop a suitable employee database application by
considering appropriate attributes.
a) Whenever the inserted or updated salary is more than 10 lacs per
month a trigger should be fired.

b) Whenever, the inserted or updated salary is less than 5000 per


month a trigger should be activated.

CREATE OR REPLACE TRIGGER salupdate


BEFORE UPDATE OF esal
ON empsal
FOR EACH ROW
BEGIN
IF :NEW.esal <= :OLD.esal THEN
raise_application_error(-20103,'Salary should be greater than current');
END IF;
END;
/

create or replace trigger emp_Sal_update1


before update on empsal for each row
begin
dbms_output.put_line('Record updated');
end;

You might also like