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
2018-07-22, 840👍, 0💬
Popular Posts:
What Is a Parameter File in Oracle? A parameter file is a file that contains a list of initializatio...
What Is a Constant or Literal in SQL Server Transact-SQL? A constant, or data literal, is a symbolic...
How To Recreate an Existing Index in SQL Server? If you want to change the definition of an existing...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
How AdventureWorksLT tables are related in SQL Server? There are 12 user tables defined in Adventure...