标签:pl/sql
procedure zuhev(n number,
arrvar out t_arrchar) is
idx number;
m number;
x number := 1;
type arrayty is table of number index by binary_integer;
-- nlarr nlarrarty;
-- arr arrayty;
p arrayty;
a arrayty;
tmps varchar2(1000);
begin
for i in 1 .. n
loop
a(i) := i;
end loop;
for i in 1 .. n
loop
p(i) := i;
end loop;
for i in 0 .. n
loop
m := i;
begin
idx := 1;
p(idx) := 1; --//取第一个元素
while (true)
loop
if (p(idx) > n) then
--//取到底了,回退
if (idx = 1) then
--//各种情况取完了,不能再回退了
exit;
end if;
--}
idx := idx - 1; --;//回退到前一个
p(idx) := p(idx) + 1; --//替换元素
-- }
elsif (idx = m) then
--//取够了,输出
for i in 1 .. m
loop
tmps := tmps || to_char(a(p(i)));
end loop;
arrvar(x) := tmps;
tmps := null;
p(idx) := p(idx) + 1; --//替换元素
x := x + 1;
else
--{//多取一个元素
idx := idx + 1;
p(idx) := p(idx - 1) + 1;
--}
end if;
end loop;
end;
end loop;
/* for i in 1 .. arrvar.count
loop
dbms_output.put_line(to_char(arrvar(i)));
end loop;*/
end;
本文出自 “ORACLE/DB2/MYSQL” 博客,谢绝转载!
标签:pl/sql
原文地址:http://383610.blog.51cto.com/373610/1740343