SQL: Beginner Guide to Store Procedures
a thread...
(Part 1/2)
a thread...
(Part 1/2)
1. What is Store Procedure?
It's a group of SQL statements stored on the DB side, to perform some action (business logic) or perform any DB-related task.
SP may or may not return output and may or may not take arguments, they are optional.
It's a group of SQL statements stored on the DB side, to perform some action (business logic) or perform any DB-related task.
SP may or may not return output and may or may not take arguments, they are optional.
4. Types of Parameters in SP:
IN: Using it, caller can pass param.
OUT: Output sent by SP to caller.
INOUT: The caller can pass the value inside SP, and SP can modify it and give it back to the caller with an updated value.
(in part 2, we'll cover this in detail)
IN: Using it, caller can pass param.
OUT: Output sent by SP to caller.
INOUT: The caller can pass the value inside SP, and SP can modify it and give it back to the caller with an updated value.
(in part 2, we'll cover this in detail)
5. Benefits of SP?
- Gives good performance, as it's precompiled in nature.
- Gets updated instantly without any deployment/server restart very useful when fixing production issues without any downtime.
- Gives good performance, as it's precompiled in nature.
- Gets updated instantly without any deployment/server restart very useful when fixing production issues without any downtime.
- Reusability, as it can be used by multiple users/clients and also it accepts parameters so the same code can be used for multiple purposes.
- Reduces network traffic, as several SQL operations can be performed with a single step and save network round trips.
- Reduces network traffic, as several SQL operations can be performed with a single step and save network round trips.
6. Drawbacks of SP:
- Errors are detected at runtime.
- Difficult to debug an SP.
- Difficult to maintain especially if it carries business logic.
- Errors are detected at runtime.
- Difficult to debug an SP.
- Difficult to maintain especially if it carries business logic.
That's it for now!
In part 2, we will see how to create store procedures with different types of parameters.
If you liked this then you might also like my other thread on SQL:
In part 2, we will see how to create store procedures with different types of parameters.
If you liked this then you might also like my other thread on SQL:
I hope you learned something new!
Every Mon, Wed & Fri - I write a thread
on Fullstack Development.
Follow @vikasrajputin to read all my future threads.
Every Mon, Wed & Fri - I write a thread
on Fullstack Development.
Follow @vikasrajputin to read all my future threads.
Part-2 is out now👇
جاري تحميل الاقتراحات...