Dbms Worksheet-3: Name: - Praduman Kumar Section: - 20ITB5 UID: - 20BCS9446
Dbms Worksheet-3: Name: - Praduman Kumar Section: - 20ITB5 UID: - 20BCS9446
Dbms Worksheet-3: Name: - Praduman Kumar Section: - 20ITB5 UID: - 20BCS9446
Code:-
create table dept(
deptno number(2,0),
dname varchar2(14),
loc varchar2(13),
constraint pk_dept primary key (deptno)
)
DELETE FROM dept WHERE dname= 'Account’
Screenshot:-
2. Create table EMP with the following description :
Name Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(3)
AGE NUMBER(3)
ESAL NUMBER
1. Get the description EMP table.
2. List all employees details.
3. List all employee names and their salaries, whose salary lies
between 1500/- and 3500/- both inclusive.
4. List all employee names and their and their manager whose
manager is 7902 or 7566 0r 7789.
5. List all employees who belongs to the department 10 or 20
Code:-
4. List all employee names and their and their manager whose manager is
7902 or 7566 0r 7789.
INPUT SQL>select ename from emp where mgr in(7602,7566,7789);
RESULT:-
ENAME
-------
SCOTT
FORD
Code:-
DECLARE
n NUMBER := 0;
BEGIN
LOOP
DBMS_OUTPUT.PUT_LINE ('The value of n inside the loop is: ' ||
TO_CHAR(n));
n := n + 1;
IF n > 5 THEN
EXIT;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('The value of n outside the loop is: ' ||
TO_CHAR(n));
END;
/
Screenshot:-
Output:-
4. Write a program in PL/SQL to print factorial of a number
Here, first, we take three variables num, fact, and temp and assign the value in
num variable (i.e which number factorial we want).
And then after we assign fact variable to 1.
Examples:
Input : 4
Output : 24
Input : 6
Output : 720
Code:-
declare
begin
temp :=num;
end loop;
end;
-- Program End
Screenshot:-
Output :-
factorial of 6 is 720.