Stored procedures in_mysql


Published on

Stored procedures in_mysql

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Stored procedures in_mysql

  1. 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  2. 2. Stored procedure Nabeel.C www.facebook/ nabilmohad +919746477551
  3. 3. STORED PROCEDURE • A stored procedure is an laready written sql statement that is saved in the database. we can run the stored procedure from the database’s enviornment. Stored procedures does not execute automatically.
  4. 4. Pre compailed execution. Sql server compailes each stored procedure once and then reutilize the execution plan.
  5. 5. Redused client/server traffic • Stored procedure reduced the traffic between application and database server because instead of sending multiple uncompiled long SQL commands statement, application only has to send the stored procedure name and get the result back. .
  6. 6. Efficient reuse of code and programming abstraction. • stored procedure can be used by multiple users and client programs. If we utlize them in a planned manner, you will find the devlopment cycle take less time.
  7. 7. Syntax:- • DELIMITER CREATE PROCEDURE procedure_name() BEGIN codes; END DELIMITER ; • In order to invoke a stored procedure we use the following SQL command: CALL STORED_PROCEDURE_NAME()
  8. 8. • DELIMITER // CREATE PROCEDURE GetAllProducts() BEGIN SELECT * FROM products; END // DELIMITER ; • Call GetAllProducts();
  9. 9. stored procedures with parameters • • Parameters make the stored procedure more flexible and useful. In MySQL, a parameter has one of three modes IN, OUT and INOUT.
  10. 10. • IN this is the default mode. IN indicates that a parameter can be passed into stored procedures but any modification inside stored procedure does not change parameter. Suppose you pass parameter Id, which is equal 10, into stored procedure GetAll(Id), after executing the stored procedure the value of Id is still 10 even though the GetAll stored procedure can change the value of it.
  11. 11. • OUT this mode indicates that stored procedure can change this parameter and pass back to the calling program. • INOUT obviously this mode is combined of IN and OUT mode; you can pass parameter into stored procedure and get it back with the new value from calling program.
  12. 12. • DELIMITER // CREATE PROCEDURE GetOfficeByCountry(IN countryName VARCHAR(255)) BEGIN SELECT city, phone FROM offices WHERE country = countryName; END // DELIMITER ;
  13. 13. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: