Salut,
Existe-t-il une solution pour ne pas bloquer l’exécution d'une fonction lorsqu'une erreur no data se produit ?
D'avance merci
Laurent
Salut,
Existe-t-il une solution pour ne pas bloquer l’exécution d'une fonction lorsqu'une erreur no data se produit ?
D'avance merci
Laurent
Bonsoir,
J'utilise les exception mais je cherche un truc équivalent à Résume next de VB car lorsqu'on est déjà dans le error handling, je ne suis pas certain que l'on puisse remonter dans le flux d'execution de la procédure.
Je vais relire le tuto plus lentement mais de prime abord, il ne résout pas mon problème.
Merci
Laurent
L'erreur se produit dans le SELECT pT.ID INTO vPrevTreatmentId
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
24
25
26
27 */ SELECT pT.ID INTO vPrevTreatmentId FROM FHR_TREATMENT pT WHERE pT.TREATMENT_DATE = ( SELECT MAX(spT.TREATMENT_DATE) FROM FHR_TREATMENT spT WHERE spT.TREATMENT_DATE<pTREATMENT_DATE ); IF vPrevTreatmentId is null THEN vPrevInst_InstValueOverId := null; vPrevInst_CompOverId := null; ELSE vPrevInst_InstValueOverId := PAK_FHR.Instr_ValueOverId_Get(vPrevTreatmentId,vInstrumentId); vPrevInst_CompOverId := PAK_FHR.Instr_CompOverId_Get(vPrevTreatmentId,vInstrumentId); vPrevComp_CompValueOverId := PAK_FHR.Comp_ValueOverId_Get(vPrevTreatmentId,vCompartimentId); vPrevComp_UmbOverId := PAK_FHR.Comp_UMBOverId_Get(vPrevTreatmentId,vCompartimentId); vPrevUmb_UmbValueOverId := PAK_FHR.Comp_ValueOverId_Get(vPrevTreatmentId,vUmbrellaId); END IF;
J'ai besoin qu'en cas d'erreur, vPrevTreatmentId := null et que l'application continue.
La seule solution à laquelle je pense est d'encapsuler le select into dans une fonction qui aurait sa propre gestion d'erreur. Ainsi je sais que j'aurais toujours un comportement conforme à les attentes.
S'il y a une solution "inline" je préfère car les personnes qui seront chargées de la maintenance n'ont pas un super niveau en Oracle
++
Laurent
La solution "inline" consiste à mettre le Select dans son propre bloc PL/SQL
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
24
25
26
27
28
29
30
31 Begin SELECT pT.ID INTO vPrevTreatmentId FROM FHR_TREATMENT pT WHERE pT.TREATMENT_DATE = ( SELECT MAX(spT.TREATMENT_DATE) FROM FHR_TREATMENT spT WHERE spT.TREATMENT_DATE<pTREATMENT_DATE ); Exception When NO_DATA_FOUND Then vPrevTreatmentId := Null; -- ça va! Le traitement peut continuer End; IF vPrevTreatmentId IS NULL THEN vPrevInst_InstValueOverId := NULL; vPrevInst_CompOverId := NULL; ELSE vPrevInst_InstValueOverId := PAK_FHR.Instr_ValueOverId_Get(vPrevTreatmentId,vInstrumentId); vPrevInst_CompOverId := PAK_FHR.Instr_CompOverId_Get(vPrevTreatmentId,vInstrumentId); vPrevComp_CompValueOverId := PAK_FHR.Comp_ValueOverId_Get(vPrevTreatmentId,vCompartimentId); vPrevComp_UmbOverId := PAK_FHR.Comp_UMBOverId_Get(vPrevTreatmentId,vCompartimentId); vPrevUmb_UmbValueOverId := PAK_FHR.Comp_ValueOverId_Get(vPrevTreatmentId,vUmbrellaId); END IF;
Ok
Merci
++
Bonjour,
encadre simplement ton select dans un bloc
Edit: grillé
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 code avant BEGIN le select EXCEPTION gestion erreur END; suite du code
Partager