Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Stored Procedures in MySQL

3,866 views

Published on

  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes.........ACCESS WEBSITE Over for All Ebooks ..... (Unlimited) ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Stored Procedures in MySQL

  1. 1. Stored Procedures in MySQLMichele Catalano I 06.10.2011 © Mayflower GmbH 2011
  2. 2. CREATE PROCEDUREI CREATE PROCEDURE name ([IN|OUT|INOUT] varname type …) Variablen definition DEFINER Manuelles definieren des Besitzers der Prozedur (default Ersteller) DETERMINISTIC Bei identischen Input gleicher Output. CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA Definiert der Sprache bzw. ob Daten nur gelesen oder auch manipuliert werden. SQL SECURITY (DEFINER | INVOKER ) Definiert mit welchen Rechten die Prozedur ausgeführt wird. BEGIN … END Block mit der eigentlichen ProzedurI delimiter Mayflower GmbH I 2
  3. 3. Grundlagen Flow ControlI IF .. ELSEIF … ELSE … ENDIFI CASE … (WHEN … THEN) … ELSE … END CASEI label: LOOP … END LOOPI [label:] REPEAT … UNTIL … END REPEATI [label:] WHILE … DO … END WHILE [label]I LEAVE labelI INTERATE label Mayflower GmbH I 3
  4. 4. DECLARE HandlerI DECLARE HANDLER TYPE CONTINUE Weiter ausführen des Codes im BEGIN...END Block EXIT Abbrechen der Ausführung des Codes im BEGIN...END Block CONDITION SQLSTATE sqlstate_value Abfangen eines bestimmten SQLSTATE Wert SQLWARNING Abfangen alle SQLSTATS die mit 01 beginnen NOT FOUND Abfangen alle SQLSTATS die mit 02 beginnen SQLEXCEPTION Abfangen alle SQLSTATS die mit 00, 01 und 02 beginnen Mayflower GmbH I 4
  5. 5. DECLARE VariablenI DECLARE VARIABLE var_name, [var_name]... type [DEFAULT value]I var_name ist alphanumerischI type ist ein valider SQL Feld Type (z.B. CHAR, VARCHAR)I value ist der Standard Wert welche der variable beim deklarieren zugewiesen wird. Mayflower GmbH I 5
  6. 6. GRUNDLAGEN CURSORI DECLARE name CURSOR FOR sqlstatement Deklarieren des CURSORS für denn SQL BefehlI OPEN name Öffnen des CURSORSI FETCH name INTO Iterieren über die Ergebnisse des CURSORS Um das Ende der Daten zu erkennen muss unbedingt ein HANDLER für NOT FOUND definiert werden.I CLOSE name Schließen des CURSORS Mayflower GmbH I 6
  7. 7. RECHTEI CREATE PROCEDUREI ALTER PROCEDUREI DROP PROCEDUREI CALL Ohne diese Recht kann keine Prozedur ausgeführt werden!!I Wenn die Prozedur mit SQL SECURITY INVOKER erstellt wurde muss der Caller auch alle rechte für die in der Prozedur verwendeten SQL Statements haben! Mayflower GmbH I 7
  8. 8. VorteileI Sehr Mächtige DatenmanipulationsmöglichkeitI Interessante Möglichkeit zusammen mit TriggerI Gut nutzbar für komplexes ReportingI Einfaches Hilfswerkzeug für Datenbank redesignI Abfragen von Daten für die der Caller nicht direkt die Rechte hat. Mayflower GmbH I 8
  9. 9. NachteileI Einbindung in ein Continues Integrations Umgebung nicht gegeben.I Testbarkeit eigentlich nicht vorhandenI Kein DebuggingI Mischung von Daten und LogikI Schlecht ein schätzbare Last auf Datenbankservern für Performance TunningI Unsicherheit im zusammenspiele mit Master/Slave bin logI Ein Caller kann durch die Prozedur auch auf Daten für die er keine Zugriffsrechte hat zugreifen. Mayflower GmbH I 9
  10. 10. QuellenverweiseI MySQL Manual: http://dev.mysql.com/doc/refman/5.1/en/stored-programs-defining.html http://dev.mysql.com/doc/refman/5.1/en/sql-syntax-compound-statements.html http://dev.mysql.com/doc/refman/5.1/en/stored-programs-logging.html http://dev.mysql.com/doc/refman/5.1/en/stored-programs-security.html http://dev.mysql.com/doc/refman/5.1/en/call.html http://dev.mysql.com/doc/refman/5.1/en/stored-routines-privileges.html http://dev.mysql.com/doc/refman/5.1/en/stored-program-restrictions.html Mayflower GmbH I 10
  11. 11. Vielen Dank für Ihre Aufmerksamkeit! Referent Michele Catalano michele.catalano@mayflower.de +49 89 242054 1 12 1 Mayflower GmbH Mannhardtstrasse 6 80538 München25.10.2011 Mayflower GmbH 11

×