CURSORES (PROMEDIO)

create table estudiantes
(codest number(4) primary key,
nomest varchar2(25),
apeest varchar2(25),
not1 number(2,1),
not2 number(2,1),
not3 number(2,1));

insert into estudiantes values (10,'camilo','rodriguez',4.6,2.9,3.5);
insert into estudiantes values (20,'jorge','cano',4.8,4.1,4.7);
insert into estudiantes values (30,'juan','gomez',2.5,2.1,1.5);
insert into estudiantes values (40,'haider','cotta',3.3,4.6,4.5);
insert into estudiantes values (50,'maicol','garcia',3.8,2.4,2.9);

select * from estudiantes;

set serveroutput on;
declare cursor notasest
is
select codest,nomest,not1,not2,not3
from estudiantes;
codest number (4);
nomest varchar2(25);
nt1 number(2,1);
nt2 number(2,1);
nt3 number(2,1);
nota1 number(3,2):= 0;
begin
  open notasest;
  loop
  fetch  notasest into codest,nomest , nt1,nt2,nt3;
  exit when  notasest%notfound;
  nota1 :=  (nt1 + nt2+nt3)/3;
  dbms_output.put_line(notasest%rowcount||'notaest:' || nota1);
  end loop;
  close  notasest;
  end;

Share this

Related Posts

Previous
Next Post »

Buscar en Wikipedia

Resultados de la búsqueda