MSK Institute • Shikohabad
Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Connecting serverPlease wait...
💻 Practical Labs🚀 Free Demo📜 Verified Certificates
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Stored procedures become truly versatile when they accept inputs and return calculated outputs dynamically. MySQL procedures support three parameter modes: IN, OUT, and INOUT.
IN (Default): Pass-by-value input parameter. The procedure receives a copy of the caller's value. The procedure can modify the variable locally, but changes are not visible to the caller outside the procedure.OUT: Pass-by-reference output parameter. The procedure initializes the parameter to NULL and assigns a value to it that is passed back to the caller upon completion.INOUT: Dual-purpose parameter. The caller provides an initial input value, and the procedure can inspect, modify, and pass the updated value back to the caller.Let's build an order fulfillment procedure that takes an IN order ID, computes an OUT total price, and updates an INOUT customer reward points balance:
To receive values from OUT and INOUT parameters, pass MySQL session user variables (prefixed with @):
If order 1001 had total_amount = 250.00:
@calculated_total is populated with 250.00.@current_points increases from 50 by FLOOR(250 / 10) = 25, yielding 75!Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Defining Stored Procedures (DELIMITER //, CREATE PROCEDURE) | Control Flow: Variables, Branches & Loops |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.