storedfunctions
TRANSCRIPT
![Page 1: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/1.jpg)
![Page 2: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/2.jpg)
Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
![Page 3: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/3.jpg)
STORED FUNCTIONS
Waseem [email protected]/us/twitter.com/usernamein.linkedin.com/in/profilename9567850028
![Page 4: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/4.jpg)
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
![Page 5: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/5.jpg)
• function can return one value which is mandatory.
• functions can have only input parameters.• function can be embedded in a select
statement.
![Page 6: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/6.jpg)
DECLARATION
• Functions are declared using the following syntax:
function <function-name> (param_spec1, …, param_speck)
returns <return_type> begin
-- execution codeend;
![Page 7: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/7.jpg)
+--------+--------+---------+-----------+----------+| 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 |+--------------+
![Page 8: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/8.jpg)
THANK YOU……..
![Page 9: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/9.jpg)
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
![Page 10: Storedfunctions](https://reader037.vdocument.in/reader037/viewer/2022110309/558902b2d8b42a7a1b8b4602/html5/thumbnails/10.jpg)
Contact Us
Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
Start up VillageEranakulam,Kerala, India.
Email: [email protected]