plsql progs
plsql progs
2. Display those managers name whose salary is more than average salary of his employees.
3. Display those employees who joined the company before 15 of the month?
Select count(*) from employee where comm is not null and comm>0;
10. Create a view,which cointain employee names and their manager names working in sales
department.
View created
12. Determine the names of employees, who take highest salary in there departments.
14. Determine the employees, who are located at the same place.
Select deptno from employee where sno is null and name is null;
no data found
pl/sql
16.
DECLARE
var_rows number(5);
BEGIN
IF SQL%NOTFOUND THEN
var_rows := SQL%ROWCOUNT;
END IF;
END;
OutPut:
None of the salaries where updated
17. Amstrong
DECLARE
n number;
num1 number;
s number;
d number;
BEGIN
n:=153;
num1:=n;
s:=0;
while n<>0
loop
d:=mod(n,10);
s:=s+(d*d*d);
n:=round(n/10);
end loop;
dbms_output.put_line(s);
if s<>num1 then
else
end if;
END;
Output:
DECLARE
a number;
b number;
BEGIN
a:=5;
b:=6;
a:=a+b;
b:=a-b;
a:=a-b;
END;
Output:
Statement processed.
20.
DECLARE
var_rows number(5);
var_sno number;
vi number;
BEGIN
var_sno:=&vi;
IF SQL%NOTFOUND THEN
var_rows := SQL%ROWCOUNT;
END IF;
END;
OutPut:
1 row(s) updated.
0.00 seconds
DECLARE
num1 number;
n number;
i number;
BEGIN
num1:=3;
i:=1;
while i<=10
loop
i:=i+1;
end loop;
i:=1;
while i<=10
loop
i:=i+1;
end loop;
END;
Output:
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
3 * 10 = 30
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70
Statement processed.
22. Prime Number
DECLARE
num number:=25;
i number:=2;
BEGIN
while i<num
loop
if(mod(num,i)<>0) then
i:=i+1;
else
exit;
end if;
end loop;
if i<>num then
else
end if;
END;
Output:
Statement processed.
0.01 seconds
24.
DECLARE
var_rows number(5);
BEGIN
IF SQL%NOTFOUND THEN
END IF;
END;
25.
is
var_rows number(5);
begin
IF SQL%NOTFOUND THEN
var_rows := SQL%ROWCOUNT;
END IF;
end;
/* To run procedure*/
BEGIN
employee_sal_update;
END;
OutPut:
There is no employee whose commission is less than 9 percentage
Statement processed.
26. Polindrum
DECLARE
num1 number;
r number;
d number;
n number;
BEGIN
num1:=121;
n:=num1;
r:=0;
while num1<>0
loop
d:=mod(num1,10);
r:=r*10+d;
num1:=round(num1/10);
end loop;
dbms_output.put_line(r);
if r=n then
else
end if;
END;
Output:
121
given number is polindrum
Statement processed.
0.00 seconds
27.
CREATE OR REPLACE PROCEDURE employee_sal_update_marc
is
var_rows number(5);
begin
update employee set sal=sal+(sal*(15/100)) where job='marc';
IF SQL%NOTFOUND THEN
dbms_output.put_line('There is no employee whos job is marcketing ');
ELSIF SQL%FOUND THEN
var_rows := SQL%ROWCOUNT;
dbms_output.put_line('Salaries of ' || var_rows || 'employees are updated');
END IF;
end;
/
Output
Procedure created.
/* To run procedure*/
BEGIN
employee_sal_update_marc;
END;
OutPut:
0.00 seconds