{"id":244,"date":"2023-02-22T17:21:55","date_gmt":"2023-02-22T16:21:55","guid":{"rendered":"http:\/\/www.sepchat.com\/SC\/?p=244"},"modified":"2023-02-23T14:53:52","modified_gmt":"2023-02-23T13:53:52","slug":"triggers-de-type-sql","status":"publish","type":"post","link":"http:\/\/www.sepchat.com\/SC\/index.php\/2023\/02\/22\/triggers-de-type-sql\/","title":{"rendered":"Triggers\u00a0de type *SQL"},"content":{"rendered":"\n<p>Un programme Trigger est d\u00e9clench\u00e9 \u00e0 chaque acc\u00e8s aux donn\u00e9es d&rsquo;un fichier (Lecture, mise \u00e0 jour, suppression &amp; affichage).<\/p>\n\n\n\n<p>Ce programme Trigger peut \u00eatre d\u00e9velopp\u00e9 au moyen d&rsquo;un langage de programmation classique, ou directement en SQL.<\/p>\n\n\n\n<p>Par exemple, pour chaque ajout dans la table SALARIES, un compteur sera incr\u00e9ment\u00e9 de 1 dans la table SOCIETE.&nbsp;&nbsp;&nbsp;CREATE TRIGGER&nbsp;NEW_SALAR<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AFTER INSERT ON&nbsp;SALARIES<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FOR EACH ROW<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE&nbsp;SOCIETE SET NBEMP = NBEMP + 1Autre exemple, le trigger cr\u00e9era une erreur si le montant de son salaire est augment\u00e9 de plus de 10 %<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;CREATE TRIGGER&nbsp;LIMIT_AUGMENT<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AFTER UPDATE OF&nbsp;SALAIRE&nbsp;ON&nbsp;SALARIES<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;REFERENCING NEW AS&nbsp;N&nbsp;OLD AS&nbsp;O<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FOR EACH ROW<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHEN&nbsp;(N.SALAIRE &gt; 1.1 * O.SALAIRE)<\/p>\n\n\n\n<p>\u00a0\u00a0\u00a0\u00a0  SIGNAL SQLSTATE\u00a0&lsquo;75000&rsquo;\u00a0SET MESSAGE_TEXT=&rsquo;Augmentation de plus de 10%&rsquo;<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized size-full has-custom-border\"><a href=\"sql\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.sepchat.com\/SC\/wp-content\/uploads\/2023\/02\/fleche-r-edited.png\" alt=\"\" width=\"57\" height=\"57\"\/><\/a><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex\">\n<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link wp-element-button\" style=\"border-radius:100px\">Cet article vous a \u00e9t\u00e9 utile ? N\u2019h\u00e9sitez pas \u00e0 le partager.<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Un programme Trigger est d\u00e9clench\u00e9 \u00e0 chaque acc\u00e8s aux donn\u00e9es d&rsquo;un fichier (Lecture, mise \u00e0 jour, suppression &amp; affichage). Ce programme Trigger peut \u00eatre d\u00e9velopp\u00e9 au moyen d&rsquo;un langage de programmation classique, ou directement en SQL. Par exemple, pour chaque ajout dans la table SALARIES, un compteur sera incr\u00e9ment\u00e9 de 1 dans la table SOCIETE.&nbsp;&nbsp;&nbsp;CREATE [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts\/244"}],"collection":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/comments?post=244"}],"version-history":[{"count":2,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":317,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/posts\/244\/revisions\/317"}],"wp:attachment":[{"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sepchat.com\/SC\/index.php\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}