Hi friends,
I have data like this in EMP table:
Emp_Id Last_Name Dept_Id Salary
------------------------------------------------------------
101 Arun 10 1000
102 Bala 20 2000
103 Arun 20 3000
104 Bala 30 4000
In PL/SQL, I need to assign Salaries of these 4 employees in 4 different local scalar variable in a single query. Something like this:
DECLARE
V_SAL_OF_101 INTEGER;
V_SAL_OF_102 INTEGER;
V_SAL_OF_103 INTEGER;
V_SAL_OF_104 INTEGER;
BEGIN
--Forget about primary key, or other constraints.
select salary
into V_SAL_OF_101
from EMP
where emp_id = 101
and last_name = 'Arun';
select salary
into V_SAL_OF_102
from EMP
where emp_id = 102
and last_name = 'Bala';
--An so on.
--Instead of querying multiple times, is it possible to assign these scalar variables in a single query (without using a collection).
END;