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, 2243🔥, 0💬
Popular Posts:
How to download Microsoft SQL Server 2005 Express Edition in SQL Server? Microsoft SQL Server 2005 E...
How to run Queries with SQL Server Management Studio Express in SQL Server? 1. Launch and connect SQ...
Where to find answers to frequently asked questions on Storage Engines: MyISAM, InnoDB and BDB in My...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...