From the course: MySQL Advanced Topics (2019)

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Creating a stored function

Creating a stored function - MySQL Tutorial

From the course: MySQL Advanced Topics (2019)

Creating a stored function

- [Instructor] A stored function is defined with the create function statement. Here in this lesson, we're going to use the album database. And, we start with this drop function if exists, and then we define the function here. You'll notice the delimiter command, this is implemented in the client, not in the server, and it simply changes the delimiter, so that I can use all of this as one statement, so the client can pass all of this create function statement to the server, even though it may contain one or more semicolons. So that's what the delimiter command is for, and again that's implemented in the client, so that it can send that whole chunk of code at once to the server. The create function statement is the beginning of the function definition. You'll notice in parenthesis here, it says seconds INT, that's the definition of a variable parameter, in this case an INT, and it's named seconds. The function returns…

Contents