plsql_e2_62136.txt
plsql_e2_62136.txt
exit;
This study source was downloaded by 100000889764202 from CourseHero.com on 08-23-2024 00:19:43 GMT -05:00
https://www.coursehero.com/file/92245530/plsql-e2-62136txt/
2- calculating bonus
exit;
This study source was downloaded by 100000889764202 from CourseHero.com on 08-23-2024 00:19:43 GMT -05:00
https://www.coursehero.com/file/92245530/plsql-e2-62136txt/
SET ECHO OFF;
SET HEADING OFF;
SET WRAP OFF;
SET LINESIZE 10000;
SET TAB OFF;
SET PAGES 0;
SET DEFINE OFF;
set serveroutput on;
update emp set dept_id=(select dept_id from dept minus select dept_id from emp)
where dept_id is null;
update emp set mgr_id=7 where dept_id=10;
alter table emp add mgr_name varchar(50);
update emp set mgr_name=(select concat(emp_fname,concat(' ',emp_lname)) from emp
e where emp.mgr_id = e.emp_id);
declare
emp_id number;
emp_fname varchar(50);
emp_lname varchar(50);
emp_status varchar(50);
dept_name varchar(50);
mgr_name varchar(50);
cursor cur is
select e.emp_id,
e.emp_fname,
e.emp_lname,
e.emp_status,
d.dept_name,
e.mgr_name
from emp e,
dept d
where e.dept_id =10
and e.dept_id=d.dept_id;
begin
open cur;
dbms_output.put_line('emp_Id emp_fname emp_Lname emp_Status Dept_name
Mgr_name');
loop
fetch cur into emp_id, emp_fname, emp_lname, emp_status, dept_name, mgr_name;
exit when cur%notfound;
dbms_output.put_line(emp_id||' '||emp_fname||' '||emp_lname||' '||emp_status||'
'||dept_name||' '||mgr_name);
end loop;
end;
/
/*
Enter your query below.
Please append a semicolon ";" at the end of the query
*/
exit;
This study source was downloaded by 100000889764202 from CourseHero.com on 08-23-2024 00:19:43 GMT -05:00
https://www.coursehero.com/file/92245530/plsql-e2-62136txt/
set serveroutput on;
select 'emp_id emp_fname emp_Lname emp_HireDate emp_Status Dept_name Mgr_name'
from dual;
select A.emp_id,
A.emp_fname,
A.emp_lname,
A.emp_hireDate,
A.emp_status,
d.Dept_name,
case
when A.Mgr_id is not null and B.emp_status = 'Active' then
concat(concat(B.emp_fname, ' '), B.emp_lname)
when A.Mgr_id is not null and B.emp_status = 'Terminated' then
'Terminated Manager'
when A.Mgr_id is null and C.emp_status = 'Active' then
concat(concat(C.emp_fname, ' '), C.emp_lname)
when A.Mgr_id is null or D.dept_head is not null or
C.emp_status = 'Terminated' then
'Terminated Manager'
end mgr_name
from emp A, dept D, emp B, emp C
where A.emp_status = 'Active'
and to_date(A.emp_hireDate, 'dd/mm/yyyy') >=
to_date('01/01/2000', 'dd/mm/yyyy')
and A.dept_id = d.dept_id (+)
and A.mgr_id = B.emp_id (+)
and C.emp_id (+)= D.dept_head
order by 1
/
exit;
This study source was downloaded by 100000889764202 from CourseHero.com on 08-23-2024 00:19:43 GMT -05:00
https://www.coursehero.com/file/92245530/plsql-e2-62136txt/
Powered by TCPDF (www.tcpdf.org)