storedfunctions

10

Upload: baabtracom-no-1-supplier-of-quality-freshers

Post on 23-Jun-2015

105 views

Category:

Business


0 download

TRANSCRIPT

Page 1: Storedfunctions
Page 2: Storedfunctions

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

STORED FUNCTIONS

Waseem [email protected]/us/twitter.com/usernamein.linkedin.com/in/profilename9567850028

Page 4: Storedfunctions

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

• 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

DECLARATION

• Functions are declared using the following syntax:

function <function-name> (param_spec1, …, param_speck)

returns <return_type> begin

-- execution codeend;

Page 7: Storedfunctions

+--------+--------+---------+-----------+----------+| 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

THANK YOU……..

Page 9: Storedfunctions

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

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]