Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews DB Oracle Interviews:Concepts and ArchitectureData AccessDatabase ArchitectureDatabase ManagementDatabase Security OracleDistributed ProcessingFlexfieldForms ReportsGeneral OracleMemory ManagementMTO-SAP Financial AccountingOCIOracle AOLOracle AROracle Backup RecoveryOracle D2KOracle DatabaseOracle Database DeveloperOracle DB OptimizationOracle DBAOracle DeveloperOracle ETLOracle Forms 3.0Oracle Forms 4.0Oracle GLOracle PL-SQLOracle RMANOracle ScenariosOracle SecurityOracle SQLOracle System ArchitectureOracle Technology Network (OTN)Programmatic ConstructsRAC (Real Application Clusters)SQL Plus
Copyright © 2018. All Rights Reserved
Oracle Database Interview Question:
Can You Assign Multiple Query Result Rows To a Variable?
Submitted by: AdministratorYou 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
Submitted by: Administrator
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
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.