我有一个表T(a, b, c, d,……),这个同时存在于生产库和历史库中.现在我需要两个表里的两列数据,用视图表达是这样
create view v_T as
select a, b
from T
where id = 1
union
select a, b
from T@remote
where id = 1;因为需要重复查询多次,且远程历史库查询速度慢,所以想搞成内存表,于是
create procedure xxx ……
type r_T is record(
a ……,
b ……);
type t_T is table of r_T;
new t_T := t_T();
old t_T := t_T();
begin
//对new和old填值
……
select max(a)
from table(new); <- 出错
end;编译时在标记处出错了,提示pls-00462在SQL语句中不允许使用本地收集类型.晕了,不是非得把r_T和t_T都给定义成全局类型吧,我只想在存储过程里使用不行?
对new和old的操作当然不会是max那么简单啦,还需要用到union或minus的操作,所以把old和new单纯当数组处理起来就太麻烦了.高手们有没有办法,不用申明成全局类型又能用sql语句操作?
create view v_T as
select a, b
from T
where id = 1
union
select a, b
from T@remote
where id = 1;因为需要重复查询多次,且远程历史库查询速度慢,所以想搞成内存表,于是
create procedure xxx ……
type r_T is record(
a ……,
b ……);
type t_T is table of r_T;
new t_T := t_T();
old t_T := t_T();
begin
//对new和old填值
……
select max(a)
from table(new); <- 出错
end;编译时在标记处出错了,提示pls-00462在SQL语句中不允许使用本地收集类型.晕了,不是非得把r_T和t_T都给定义成全局类型吧,我只想在存储过程里使用不行?
对new和old的操作当然不会是max那么简单啦,还需要用到union或minus的操作,所以把old和new单纯当数组处理起来就太麻烦了.高手们有没有办法,不用申明成全局类型又能用sql语句操作?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货