Curseur pl sql
Fermé
infsql
-
24 avril 2010 à 18:16
infsql Messages postés 1 Date d'inscription samedi 24 avril 2010 Statut Membre Dernière intervention 1 mai 2010 - 1 mai 2010 à 13:01
infsql Messages postés 1 Date d'inscription samedi 24 avril 2010 Statut Membre Dernière intervention 1 mai 2010 - 1 mai 2010 à 13:01
1 réponse
infsql
Messages postés
1
Date d'inscription
samedi 24 avril 2010
Statut
Membre
Dernière intervention
1 mai 2010
1 mai 2010 à 13:01
1 mai 2010 à 13:01
bonjour,
voici la réponse :
SET SEVEROUTPUT ON
ACCEPT s_num prompt'donnez le num DE n : '
declare
cursor c_empl is select ename from empl order by date_emb asc;
v_nom empl.ename%type;
v_nsuiv number;
n number;
p number;
begin
select count(*) into n from empl;
open c_empl;
p:=&n_num;
for i in 1..n loop
fetch c_empl into v_nom;
if(i=p) then
DBMS_OUTPUT.put_line('le nom : '||v_nom);
v_nsuiv:=i+1;
end if;
if(i=v_nsuiv) then
DBMS_OUTPUT.put_line('le nom n+1 est:'||v_nom);
end if;
end loop;
end;
voici la réponse :
SET SEVEROUTPUT ON
ACCEPT s_num prompt'donnez le num DE n : '
declare
cursor c_empl is select ename from empl order by date_emb asc;
v_nom empl.ename%type;
v_nsuiv number;
n number;
p number;
begin
select count(*) into n from empl;
open c_empl;
p:=&n_num;
for i in 1..n loop
fetch c_empl into v_nom;
if(i=p) then
DBMS_OUTPUT.put_line('le nom : '||v_nom);
v_nsuiv:=i+1;
end if;
if(i=v_nsuiv) then
DBMS_OUTPUT.put_line('le nom n+1 est:'||v_nom);
end if;
end loop;
end;