Hello Everyone,
Good afternoon, how are you. I hope you all guys will happy and good. By the grace of God, I am also good. Today i am here with new post in which we will learn and discuss about PLSQL Cursors.
In the last lecture we have discuss about the procedure at initial stage, but there are many things in procedure that we will choose one by one and discuss on it later.
When we use a select statement in PL/SQL, we fetch a bunch of records that match certain rules. But sometimes, we don't need all those records at once. Cursors help with that. They let us grab rows one by one, so we can work with each one separately.
Imagine we have a big bunch of data set and we need to do different things with each record like doing math operations and changing it or checking it. Cursors help with that. It is like a tool that grabs each record of data one at a time, so you can work on them separately. It is like having a pointer that guides you through the data step by step.
Types of Cursors.
- Implicit cursors
- Explicit cursors
Oracle automatically makes implicit cursors when you run an SQL statement. When we do DML operations like INSERT, UPDATE, or DELETE, there is an implicit cursor linked to it. For INSERT, it holds the data that we are inserting. For UPDATE and DELETE, it points out which rows are being changed.
We have a table called employees with columns for employee ID and salary. We will get the salary of particular employee by using his employee ID. It is the Implicit cursor example.
DECLARE
e_id employees.employee_id%TYPE := 5;
v_sal employees.salary%TYPE;
BEGIN
SELECT salary INTO v_sal
FROM employees
WHERE employee_id = e_id;
DBMS_OUTPUT.PUT_LINE(' Employee Income : ' v_sal) ;
END;
Implicit cursors are handy when we are dealing with basic queries and just need to grab one row or value. But if our situation gets more complicated like when we need precise control over cursor actions or are handling multiple rows then explicit cursors give us more freedom and control.
It would be my pleasure if you will share your opinion and reviews on this topic.
Please cast witness vote to @bangla.Witness or set proxy to @rme.
_
Vote @bangla.witness as witness
Set Proxy @rme as proxy
Special Thanks.
Cc: @rme
Cc: @hungry-griffin
Cc: @pennsif
Thanks for giving your precious time to my post.
Follow | Upvote | Share | Comments
Follow me on Instagram.
Instagram
🆃🅷🅰️🅽🅺 🆈🅾️🆄
Upvoted! Thank you for supporting witness @jswit.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit