DELIMITER // DROP PROCEDURE IF EXISTS groupe_employes // DROP PROCEDURE groupe_employes // CREATE PROCEDURE groupe_employes(IN pren VARCHAR(10)) BEGIN DECLARE s INT DEFAULT 0; SELECT * FROM employes WHERE prenom=pren; SELECT salaire FROM employes WHERE prenom = pren INTO s; IF s > 3000 THEN SELECT CONCAT(pren, ' fait partie du Groupe 1 avec ', s, ' de salaire mensuel') AS résultat; ELSEIF s >= 2000 AND s <= 3000 THEN SELECT CONCAT(pren, ' fait partie du Groupe 2 avec ', s, ' de salaire mensuel') AS résultat; ELSEIF s < 2000 AND s > 0 THEN SELECT CONCAT(pren, ' fait partie du Groupe 3 avec ', s, ' de salaire mensuel') AS résultat; ELSE SELECT CONCAT('employe inconnu', ' - ', s) AS résultat; END IF; END // CALL groupe_employes('Guillaume') // CALL groupe_employes('Damien') // CALL groupe_employes('Laura') // CALL groupe_employes('mauvais prenom') //Dans cet exemple, nous utiliserons des conditions IF, ELSEIF, ELSE pour définir le groupe d'un employé.
DROP PROCEDURE [nom de la procedure] //Pour observer les procédures existantes :
SHOW PROCEDURE STATUS// SHOW PROCEDURE STATUS \G //
SQL
1. Base De Donnees 2. Modelisation Base De Donnees 3. Requete De Selection Select 4. Requete D'insertion Insert 5. Requete De Modification Update 6. Requete De Supression Delete 7. Exercice Requete 8. Requete Imbriquee 9. Jointure 10. Union 11. Function 12. Table Virtuelle 13. Table Temporaire 14. Transaction 15. Variable Et Requete Preparee 16. Procedure Stockee 17. Trigger 18. Event 19. Entrainement Evaluation 20. Contraintes Integrite