--使用type定义二唯数组
declare
type iCountType is table of integer index by binary_integer;
i number;
j number := 5;
icount iCountType;
jcount iCountType;
begin
--初始化
icount(1) := 1;
jcount(1) := 1;
for i in 2 .. j
--初始化 5*2 的二唯数组
loop
icount(i) := icount(i - 1) * 10;
jcount(i) := jcount(i - 1) * 20;
end loop;
for i in 2 .. j
loop
dbms_output.put_line(icount(i)||','||jcount(i));
end loop;
end;
declare
type iCountType is table of integer index by binary_integer;
i number;
j number := 5;
icount iCountType;
jcount iCountType;
begin
--初始化
icount(1) := 1;
jcount(1) := 1;
for i in 2 .. j
--初始化 5*2 的二唯数组
loop
icount(i) := icount(i - 1) * 10;
jcount(i) := jcount(i - 1) * 20;
end loop;
for i in 2 .. j
loop
dbms_output.put_line(icount(i)||','||jcount(i));
end loop;
end;
本文通过一个具体的示例介绍了如何在PL/SQL中定义并初始化一个二维数组,并展示了如何利用循环来遍历这个数组并输出其元素。该过程涉及到变量声明、循环结构以及数组操作等基本概念。
1648

被折叠的 条评论
为什么被折叠?



