Join Bill Weinman for an in-depth discussion in this video Creating a stored function, part of MySQL Essential Training.
…A stored function is defined with the create function statement.…For this exercise we'll be using the album data base.…MySQL provides a function for converting seconds…to time, but I usually need to reformat…it as a string anyway, so I tend to use a stored function like this one.…Create function, and we'll call this track_len.…And it takes one parameter, seconds and it's an integer.…It returns a VARCHAR and it's not a very long one so 16 bytes will do.…
And it's deterministic, what deterministic means is that this function…will always return the same value for the same input.…And tagging it as deterministic like this, helps…the optimizer in MySQL to create more efficient code.…The default is not deterministic, so you want to put this in if your code…is going to always return the same value…for the same input, and this certainly will.…Return concat with separator and uses a colon for…separator and starts with seconds DIV 60.…
So that's the minutes part, and then we're going to use LPAD,…which is a string function that pads the left side of a string.…
- Writing queries
- Creating and updating databases and tables
- Using MySQL built-in functions
- Sorting and filtering data
- Updating tables with triggers
- Working with subselects and views
- Creating and using a stored function
Skill Level Beginner
1. Installing and Configuring the Test Environment
2. Basic Syntax
3. Creating a Database
4. MySQL Data Types
5. MySQL Functions
8. Subselects and Views
9. Stored Routines
10. PHP's PDO Interface with MySQL
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.