声明一个varchar2长度20的类型,名为 org_names。(相当于JAVA里声明一个类):
create or replace type org_names is table of varchar2(20)
定义一个类型为org_names 的变量,变量名为nt_names:
nt_names org_names := org_names();
给变量赋值,关键字BULK COLLECT 可以取出多条数据放进nt_names变量里
FOR c_org IN (SELECT org_no FROM sgpm.o_org WHERE p_org_no = in_org)
LOOP
SELECT org_no BULK COLLECT INTO nt_names FROM sgpm.o_org
START WITH org_no = c_org.org_no CONNECT BY PRIOR org_no = p_org_no;
nt_names_all := nt_names_all MULTISET UNION DISTINCT