Collections:
Error: Exact Fetch Returns More Rows in Oracle
Can You Assign Multiple Query Result Rows To a Variable in Oracle?
✍: FYIcenter.com
You can use "SELECT ... INTO variable" to assign query results to variables. But what happens if the SELECT statements return multiple rows? The answer is that you will get a run time error. The following tutorial exercise shows this error condition:
DECLARE
fname VARCHAR2(10);
lname VARCHAR2(10);
BEGIN
SELECT first_name, last_name INTO fname, lname
FROM employees WHERE employee_id = 100;
DBMS_OUTPUT.PUT_LINE('Name = ' || fname || ' ' || lname);
SELECT first_name, last_name INTO fname, lname
FROM employees WHERE employee_id > 100;
DBMS_OUTPUT.PUT_LINE('Name = ' || fname || ' ' || lname);
END;
/
ORA-01422: exact fetch returns more than requested number
of rows
ORA-06512: at line 8
Name = Steven King
⇒ Invoke Built-in Functions in PL/SQL in Oracle
⇐ Assign Query Results to Variables in Oracle
2018-09-24, 3288🔥, 0💬
Popular Posts:
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...
How To Convert Character Strings into Numeric Values in SQL Server Transact-SQL? Sometimes you need ...
How To Connect ASP Pages to Oracle Servers in Oracle? If you are running Windows IIS Web server and ...
How to connect SQL Server Management Studio Express to SQL Server 2005 Express in SQL Server? Once y...