Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Can You Assign Multiple Query Result Rows To a Variable
Can You Assign Multiple Query Result Rows To a Variable? - Oracle DBA FAQ - Working with Database Objects in PL/SQL
✍: 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
2007-04-27, 5688👍, 0💬
Popular Posts:
What will be printed as the resultof the operation below: int x; int modifyvalue() { return(x+=10); ...
What Is the Data Pump Import Utility? - Oracle DBA FAQ - Loading and Exporting Data Oracle Data Pump...
How To Download and install PSP Evaluation? - PSP Tutorials - Fading Images to Background Colors wit...
What Is the "@SuiteClasses" Annotation? "@SuiteClasses" is a class annotation defined in JUnit 4.4 i...
Which one of the following statements is TRUE in regard to overloading the ++ operator? 1 You cannot...