Mybatis调用函数,返回联合数组的配置文件如何配置?
定义了一个type,然后定义了一个table联合数组,函数的返回值为数组:代码如下:
--创建type对象
create or replace type date_type as object (
i number,
dt date
);
--创建table对象,联合数组
create or replace type table_date_type as table of date_type;
--返回范围内的日期对象
create or replace function date_range(fromDate in date,toDate in date)
return table_date_type
as
curDate date:=fromDate;
tableDate table_date_type:=table_date_type();
begin
while curDate<= toDate
loop
tableDate.EXTEND;--扩展数组空间
tableDate(tableDate.count):=date_type(tableDate.count,curDate);--table.count 数组索引,从1开始
curDate:=curDate+1;
end loop;
return tableDate;
end date_range;