• Agregue un atributo a la tabla EMPLOYEES, denominado TipoId, que va a contener un string.
• Desarrolle un cursor que permita completar dicho atributo de acuerdo al siguiente criterio:
SI employee_id es Par
Entonces
TipoId = ‘PAR’
Si-no
TipoId = ‘IMPAR’
---------------------------------------------------------------------------------------ALTER TABLE employees
MODIFY TipoId Varchar(10);
declare
vEmployee_id employees.employee_id%TYPE;
vTipo employees.first_name%TYPE;
cursor parImparCursor is
select employee_id
from employees for update;
begin
open parImparCursor;
loop
fetch parImparCursor into vEmployee_id;
IF MOD(vEmployee_id,2)=0 THEN
update employees set idtipo ='par' where MOD(Employee_id,2)=0 ;
dbms_output.put_line(vEmployee_id||' PAR ');
ELSE
dbms_output.put_line(vEmployee_id||' IMPAR ');
update employees set idtipo = 'impar';
END IF;
exit when parImparCursor%NOTFOUND;
end loop;
CLOSE parImparCursor;
end;
---------------------------------------------------------------------------------------
No hay comentarios.:
Publicar un comentario