oracle 存储过程 数组循环

table: student
name age
小一 14
小可 12
小二 17
小萨 18
写一个存储过程,定义一个数组或集合变量,循环把每个age +1
declare
type typ_rec is record of (student.name%type, student.age%type); --集合变量
type typ_tab is table of typ_rec index by binary_integer; --以集合变量为单位的仔穗模table数组
rec_sql typ_rec;
another_rec student%rowtype; --跟rec_sql一样族轿
begin
--for循念缓环里的rec_tmp不用定义,可以自动生成的
for rec_tmp in (select t.name, t.age from student t) loop
dbms_output.putline(rec_tmp.name || ' ''s age + 1 = ' || to_char(rec_tmp.age + 1) );
end loop;
exception
when others then
return;
end;
12
oracle 存储过程 数组循环
← 上一篇: 下一篇: →