Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
create or replace procedure abc_sp
(
empID IN integer
)
as
BEGIN
declare
employee_id number(6);
first_name varchar2(20);
LAST_NAME varchar2(25);
JOB_ID varchar2(10);
hire_date date;
salary number(8,2);
newSalary number(8,2);
counter NUMBER(10):= 0;
CURSOR EMPLOYEE_CURSOR IS
SELECT
employee_id,
first_name,
last_name,
job_id,
hire_date,
salary
FROM employees FOR UPDATE;
except_old_friend Exception;
except_never_met_them Exception;
begin
DBMS_OUTPUT.ENABLE(600000);
SELECT
employee_id,
first_name,
last_name,
job_id,
hire_date,
salary
into
employee_id,
first_name,
last_name,
job_id,
hire_date,
salary
from employees
where employees.employee_id = empID; -- will raise an error if data not found
DBMS_OUTPUT.PUT_LINE('Next');
OPEN EMPLOYEE_CURSOR;
FETCH EMPLOYEE_CURSOR
into
employee_id,
first_name,
last_name,
job_id,
hire_date,
salary;
if(first_name = '$$$$$')
then
RAISE except_old_friend;
elsif(last_name = 'fox')
then
RAISE except_never_met_them;
else
dbms_output.put_line( first_name||' ' ||last_name|| ' is OK');
end if;
WHILE(EMPLOYEE_CURSOR%found)LOOP
counter := counter + 1; -- Increment debug counter
newSalary := salary * 1.05;
update employees
set salary = newSalary WHERE CURRENT OF EMPLOYEE_CURSOR;
DBMS_OUTPUT.PUT_LINE('counter = '||counter||' Employee name is '||first_name||
' '||last_name||' and salary is '||newSalary);
FETCH EMPLOYEE_CURSOR
into
employee_id,
first_name,
last_name,
job_id,
hire_date,
salary;
END LOOP;
CLOSE EMPLOYEE_CURSOR;
EXCEPTION
WHEN no_data_found
then
DBMS_OUTPUT.PUT_LINE('Employee record with employee_id = ' || empID || ' not found');
WHEN except_old_friend
then
dbms_output.put_line('I know this person ' || first_name ||' ' ||last_name);
WHEN except_never_met_them
then
dbms_output.put_line('I do not know this person ' || first_name ||' ' ||last_name);
WHEN others
then
dbms_output.put_line('Oracle error number : '|| sqlcode|| ' and message '||sqlerrm);
end;
END abc_sp;