Storedfunctions

192 views

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
192
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Storedfunctions

  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 FUNCTIONS Waseem hassan wazeeem456@gmail.com www.facebook.com/us/ twitter.com/username in.linkedin.com/in/profilena me 9567850028
  3. 3. A function: • Is a named SQL block that returns a value • Can be stored in the database as a schema object for repeated execution • Is called as part of an expression or is used to provide a parameter value
  4. 4. • function can return one value which is mandatory. • functions can have only input parameters. • function can be embedded in a select statement.
  5. 5. DECLARATION • Functions are declared using the following syntax: function <function-name> (param_spec1, …, param_speck) returns <return_type> begin -- execution code end;
  6. 6. +--------+--------+---------+-----------+----------+ | enrlno | rollno | name | city | mobile | +--------+--------+---------+-----------+----------+ | 20 | 1 | paul | cochin | 96754555 | | 11 | 2 | akhil | delhi | 98756579 | | 6 | 4 | maya | bangalore | 98734534 | | 3 | 5 | sandeep | delhi | 84865644 | | 1 | 8 | anoop | bangalore | 93456535 | +--------+--------+---------+-----------+----------+ delimiter // CREATE FUNCTION get_name(id int) RETURNS varchar(20) BEGIN declare nam varchar(20); SELECT name INTO nam FROM student WHERE enrlno = id; RETURN nam; END // select get_name(11)// +--------------+ | get_name(11) | +--------------+ | akhil | +--------------+
  7. 7. THANK YOU……..
  8. 8. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  9. 9. 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: info@baabtra.com

×