Bonjour à tous,
J'ai de nouveau un problème. J'obtiens une erreur "ORA-01422: exact fetch returns more than requested number of rows". Je suis sous l'appli Apex.
Il s'agit juste d'un code pour s'exercer, le but étant de multiplier deux valeurs "nombre_a" et "nombre_b" ensemble pour remplir le champ "resultat". Puis d'attribuer une valeur à "avis" en fonction de la valeur de "resultat" (< ou > 10). Puis avec l'aide d'un curseur, d'afficher les multiplications.
Si vous aviez une explication ça m'arrangerait bien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 DECLARE CURSOR aff_resultat IS SELECT nombre_a,nombre_b,resultat FROM nom_test WHERE RESULTAT IS NOT NULL; c_resultat number; c_nombrea number; c_nombreb number; c_resultat_temp number; BEGIN UPDATE nom_test SET RESULTAT = NOMBRE_A * NOMBRE_B; SELECT resultat into c_resultat_temp from nom_test; IF c_resultat_temp < 10 then UPDATE nom_test set avis = 'Not OK'; ELSE update nom_test set avis = 'OK'; END IF; OPEN aff_resultat; LOOP FETCH aff_resultat into c_nombrea,c_nombreb,c_resultat; EXIT WHEN aff_resultat%NOTFOUND; DBMS_OUTPUT.put_line(c_nombrea || '*' || c_nombreb || '=' || round(c_resultat,2)); END LOOP; CLOSE aff_resultat; EXCEPTION WHEN TOO_MANY_ROWS THEN dbms_output.put_line(SQLERRM); END;
Partager