Instead of sending the same five statements from every app, save them once inside the database under a name — then call them like a function.
1 Stored procedure
CREATE PROCEDURE saves a named block of SQL in the database itself, ready to run again and again.
2 Parameters
IN parameters are inputs filled at call time — one procedure can serve every employee.
3 CALL
CALL give_raise(Dev, 5000) runs the stored body with your arguments plugged in.
4 Functions return
A stored function is the sibling that RETURNS a value you can use right inside a SELECT.
Programs that live in the database
Stored procedure1CREATE PROCEDURE saves a named block of SQL in the database itself, ready to run again and again. Parameters2IN parameters are inputs filled at call time — one procedure can serve every employee. CALL3CALL give_raise(Dev, 5000) runs the stored body with your arguments plugged in. Functions return4A stored function is the sibling that RETURNS a value you can use right inside a SELECT. 4 building blocks make up Programs that live in the database
Press play: the body is stored once, and CALL runs it with real arguments — parameters fill in as the body executes.
CREATE PROCEDURE stores a named block of SQL inside the database itself — ready to run again and again.
Memory
no variables yet — press play
Click each stage — from one CALL line to rows changed in the table.
Click a term, then click its description to lock the pair.
5 conceptsTap a card to expand ?Stored proceduredrops into place
?CALLdrops into place
?IN parameterdrops into place
?Stored functiondrops into place
?Bodydrops into place
This stored function pays 10 percent. What does the SELECT return?
Your predicted output — one line per console line
Hint: The function runs once per row: 10 percent of 62000 is 6200. Marketing has only Finn.
01A stored procedure is a saved SQL script the database executes on CALL.
02Parameters make one procedure serve many different cases.
03Functions RETURN a value; procedures perform actions.
04Logic in the database means one tested copy — not one per app.
05CALL replaces whole bundles of statements with a single line.