Bonjour,

Je désirerais dans la limite du possible, arrêter ma procédure si aucun enregistrement n'est retourné par une requête, j'ai donc écrit la procédure suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
CREATE PROCEDURE test(IN pindex VARCHAR(15))
<div style="margin-left:40px">BEGIN</div><div style="margin-left:40px"><div style="margin-left:40px">DECLARE flag BOOLEAN DEFAULT 0;</div></div><div style="margin-left:40px"><div style="margin-left:40px">BEGIN</div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">DECLARE EXIT HANDLER FOR NOT FOUND</div></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">SET flag :=1;</div></div></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">SELECT * FROM tl_client WHERE index_client = pindex;</div></div></div><div style="margin-left:40px"><div style="margin-left:40px">END;</div></div><div style="margin-left:40px"><div style="margin-left:40px">IF flag THEN</div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">SELECT 'ko';</div></div></div><div style="margin-left:40px"><div style="margin-left:40px">ELSE</div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">SELECT 'ok';</div></div></div><div style="margin-left:40px"><div style="margin-left:40px">END IF;</div></div><div style="margin-left:40px">END;</div>
Mais ça ne fonctionne pas, quel que soit ne résultat de la requete, c'est toujours 'ok' qui s'affiche

J'ai fait pas mal de recherche sur le net, mais pas moyen de trouver d'où venait l'erreur.

Merci par avance pour votre aide!