declare
cm Pilote.comm%type;
dt Pilote.embauche%type;
begin
select comm, embauche into cm, dt from Pilote;
end;
where
子句),或者-如果您想选择更多行,则以不同的方式(例如,放入数组)。 例如:
SQL> set serveroutput on;
SQL>
SQL> declare
2 l_dname dept.dname%type;
3 l_loc dept.loc%type;
4 begin
5 select dname, loc
6 into l_dname, l_loc
7 from dept
8 where deptno = 10;
9 dbms_output.put_line(l_dname);
10 end;
11 /
ACCOUNTING
PL/SQL procedure successfully completed.
SQL>
或
SQL> declare
2 type l_dept is table of dept%rowtype;
3 dept_arr l_dept;
4 begin
5 select deptno, dname, loc
6 bulk collect into dept_arr
7 from dept;
8
9 for i in dept_arr.first .. dept_arr.last loop
10 dbms_output.put_line(dept_arr(i).dname);
11 end loop;
12 end;
13 /
ACCOUNTING
RESEARCH
SALES
OPERATIONS
PL/SQL procedure successfully completed.
SQL>