Collections:
Retrieve Data from an Explicit Cursor in Oracle
How To Retrieve Data from an Explicit Cursor in Oracle?
✍: FYIcenter.com
If you have a cursor opened ready to use, you can use the FETCH ... INTO statement to retrieve data from the cursor into variables. FETCH statement will:
Here is a sample script showing you how to use FETCH statement:
CREATE OR REPLACE PROCEDURE FYI_CENTER AS
CURSOR t_list IS SELECT first_name, last_name
FROM employees;
f_name VARCHAR2(10);
l_name VARCHAR2(10);
BEGIN
OPEN t_list;
FETCH t_list INTO f_name, l_name;
DBMS_OUTPUT.PUT_LINE('Name = ' || f_name || ' '
|| l_name);
FETCH t_list INTO f_name, l_name;
DBMS_OUTPUT.PUT_LINE('Name = ' || f_name || ' '
|| l_name);
-- FETCH t_list INTO l_name; -- must have two variables
CLOSE t_list;
END;
/
Name = Ellen Abel
Name = Sundar Ande
⇒ Retrieve Data from a Cursor to a RECORD in Oracle
⇐ Open and Close an Explicit Cursor in Oracle
2018-07-22, 2482🔥, 0💬
Popular Posts:
What Happens to Your Transactions When ERROR 1213 Occurred in MySQL? If your transaction receives th...
How To Enter Unicode Character String Literals in SQL Server Transact-SQL? Unicode characters are mu...
How To Get the Definition of a User Defined Function Back in SQL Server Transact-SQL? If you want ge...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, y...