SELECT-INTO
Simple Selectdeclare
l_last_name employees.last_name%type;
begin
select last_name
into l_last_name
from employees
where employee_id=138;
dbms_output.put_line(l_last_name);
end;
Join
declare
l_last_name employees.last_name%type;
l_department_name departments.department_name%type;
begin
select last_name, department_name
into l_last_name, l_department_name
from employees e, departments d
where e.department_id=d.department_id
and e.employee_id=138;
dbms_output.put_line(
l_last_name||
' is working in '||
l_department_name ||
' department.');
end;
Cursor FOR Loop
declare
cursor test_cur
is
select * from employees
where department_id=50;
begin
for c1
in test_cur
loop
dbms_output.put_line(
c1.first_name||
' '||
c1.last_name
);
end loop;
end;
Comments
Post a Comment