Database Management System
Database Management System
Submitted by
Shubham Goswami (0902CS171054)
B.Tech. Computer Science & Engineering 5th Semester
(2017-2021 batch)
Problem Description: Write a pl/sql for select, insert, update and delete statements.
Solution:
Table : Friends
INSERT Command :-
UPDATE Command :-
Problem Description: Display name, hire date of all employees using cursors.
Table : Employee
Output:
Problem Description: Display details of first 5 highly paid employees using cursors.
Solution:
ENAME EMPNO SAL
---------- ----------- -------------------------------
KING 7839 5000
SCOTT 7788 3000
FORD 7902 3000
JONES 7566 2975
BLAKE 7698 2850
CLARK 7782 2450
ALLEN 7499 1600
TURNER 7844 1500
MILLER 7934 1300
WARD 7521 1250
MARTIN 7654 1250
ADAMS 7876 1100
JAMES 7900 950
SMITH 7369 800
PL/SQL Block
DECLARE
CURSOR c1 is
SELECT ename, empno, sal FROM emp
ORDER BY sal DESC; -- start with highest paid employee
Output:
Problem Description: W
rite a database trigger which fires if you try to insert, update, or
delete after 7’o’ clock.
Solution:
DECLARE
A VARCHAR2(10);
BEGIN
SELECT TO_CHAR(SYSDATE,'HH:MI') INTO A FROM DUAL;
IF A > '07:00' then
RAISE_APPLICATION_ERROR(-20500,'YOU CANT DO THIS OPERATION NOW');
END IF;
END
OUTPUT : -
ERROR at line 1:
ORA-20500: YOU CAN’T DO THIS OPERATION NOW
ORA-06512: at "GEETHA.GEETIME", line 6
ORA-04088: error during execution of trigger 'GEETHA.GEETIME