3 个解决方案
#1
怎么没人回答啊?
#2
在存储过程 使用数组循环出值
type TName is table of varchar2(80) index by binary_integer; --数组
cursor c1 is select name from student;
tmpName TName;
tmpReturn varchar2(200); //返回
ind number default 1;
begin
for c in c1 loop
tmpName(ind):=c.name;
tmpReturn:=tmpReturn||','||tmpName(ind);
ind:=ind+1;
end loop;
end;
type TName is table of varchar2(80) index by binary_integer; --数组
cursor c1 is select name from student;
tmpName TName;
tmpReturn varchar2(200); //返回
ind number default 1;
begin
for c in c1 loop
tmpName(ind):=c.name;
tmpReturn:=tmpReturn||','||tmpName(ind);
ind:=ind+1;
end loop;
end;
#3
呵,写了个函数,其实早写对了,只是犯了个小错误,所以没弄出来,谢谢2楼.
create or replace function GetTaskPlanCableNames()
return varchar2
as
retValue varchar2(2000);
begin
DECLARE
TYPE V_FIDs IS VARRAY(10000) of varchar2(3000);
eNames V_FIDs;
begin
select t.col BULK COLLECT INTO eNames from tablename t
for I IN 1..eNames.COUNT LOOP
retValue := retValue || eNames(i) || ',';
END LOOP;
END;
return retValue;
end;
create or replace function GetTaskPlanCableNames()
return varchar2
as
retValue varchar2(2000);
begin
DECLARE
TYPE V_FIDs IS VARRAY(10000) of varchar2(3000);
eNames V_FIDs;
begin
select t.col BULK COLLECT INTO eNames from tablename t
for I IN 1..eNames.COUNT LOOP
retValue := retValue || eNames(i) || ',';
END LOOP;
END;
return retValue;
end;
#1
怎么没人回答啊?
#2
在存储过程 使用数组循环出值
type TName is table of varchar2(80) index by binary_integer; --数组
cursor c1 is select name from student;
tmpName TName;
tmpReturn varchar2(200); //返回
ind number default 1;
begin
for c in c1 loop
tmpName(ind):=c.name;
tmpReturn:=tmpReturn||','||tmpName(ind);
ind:=ind+1;
end loop;
end;
type TName is table of varchar2(80) index by binary_integer; --数组
cursor c1 is select name from student;
tmpName TName;
tmpReturn varchar2(200); //返回
ind number default 1;
begin
for c in c1 loop
tmpName(ind):=c.name;
tmpReturn:=tmpReturn||','||tmpName(ind);
ind:=ind+1;
end loop;
end;
#3
呵,写了个函数,其实早写对了,只是犯了个小错误,所以没弄出来,谢谢2楼.
create or replace function GetTaskPlanCableNames()
return varchar2
as
retValue varchar2(2000);
begin
DECLARE
TYPE V_FIDs IS VARRAY(10000) of varchar2(3000);
eNames V_FIDs;
begin
select t.col BULK COLLECT INTO eNames from tablename t
for I IN 1..eNames.COUNT LOOP
retValue := retValue || eNames(i) || ',';
END LOOP;
END;
return retValue;
end;
create or replace function GetTaskPlanCableNames()
return varchar2
as
retValue varchar2(2000);
begin
DECLARE
TYPE V_FIDs IS VARRAY(10000) of varchar2(3000);
eNames V_FIDs;
begin
select t.col BULK COLLECT INTO eNames from tablename t
for I IN 1..eNames.COUNT LOOP
retValue := retValue || eNames(i) || ',';
END LOOP;
END;
return retValue;
end;