Collections:
Use FETCH Statement in a Loop in Oracle
How To Use FETCH Statement in a Loop in Oracle?
✍: FYIcenter.com
If you have a cursor opened ready to use, you can also use the FETCH statement in a loop to retrieve data from the cursor more efficiently. But you need to remember to use an EXIT statement break the loop when the cursor pointer reaches the end. The script below gives you a good example:
CREATE OR REPLACE PROCEDURE FYI_CENTER AS CURSOR emp_cur IS SELECT * FROM employees WHERE manager_id = 101; emp_rec employees%ROWTYPE; BEGIN OPEN emp_cur; LOOP FETCH emp_cur INTO emp_rec; EXIT WHEN emp_cur%NOTFOUND; DBMS_OUTPUT.PUT_LINE('Name = ' || emp_rec.first_name || ' ' || emp_rec.last_name); END LOOP; CLOSE emp_cur; END; / Name = Nancy Greenberg Name = Jennifer Whalen Name = Susan Mavris Name = Hermann Baer Name = Shelley Higgins
⇒ Use an Explicit Cursor without OPEN Statements in Oracle
⇐ Retrieve Data from a Cursor to a RECORD in Oracle
2018-04-07, 1492🔥, 0💬
Popular Posts:
How to download and install Microsoft .NET Framework Version 2.0 in SQL Server? .NET Framework Versi...
How To Convert Binary Strings into Hexadecimal Character Strings in SQL Server? When a query returns...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
What Happens If the UPDATE Subquery Returns Multiple Rows in SQL Server? If a subquery is used in a ...