我正在开发亚马逊红移,我试图将数据从视图插入到表中。
例如,
INSERT INTO TABLE1
SELECT COL1, COL2, COL3, COL4 FROM VIEW1;
当我尝试运行此命令时,它失败并出现以下错误
SQL Error [XX000]: ERROR: This type of correlated subquery pattern is not supported due to internal error
现在,当我只运行选择查询时,它运行良好。错误的原因可能是什么,因为文档中提到了确切的语法
下面是查看查询
create or replace view schema1.tmp_v as
with PP_WS_FLG as (
select YM,
case mod(substring(YM,1,4),2) when 0 then 'Y1' else 'Y2' end as DISP_YEAR_JAN,
case mod(to_char(add_months(to_date(YM,'YYYYMM'), -3),'YYYY'),2) when 0 then 'Y1' else 'Y2' end as DISP_YEAR_APR,
substring(YM,5,6) as DISP_MON,
substring(YM,1,4) || '/1 - ' || substring(YM,1,4) || '/12' as FILTER_1YEAR_JAN,
to_char(add_months(to_date(YM,'YYYYMM'), -3),'YYYY') || '/4 - ' || to_char(add_months(to_date(YM,'YYYYMM'), + 9),'YYYY') || '/3' as FILTER_1YEAR_APR,
case mod(substring(YM,1,4),2) when 0 then substring(YM,1,4) || '/1 - ' || (substring(YM,1,4) + 1) || '/12' else (substring(YM,1,4) -1) || '/1 - ' || substring(YM,1,4) || '/12' end as FILTER_2YEAR_JAN,
case mod(to_char(add_months(to_date(YM,'YYYYMM'), -3),'YYYY'),2) when 0 then to_char(add_months(to_date(YM,'YYYYMM'), -3),'YYYY') || '/4 - ' || to_char(add_months(to_date(YM,'YYYYMM'), + 21),'YYYY') || '/3' else to_char(add_months(to_date(YM,'YYYYMM'), -15),'YYYY') || '/4 - ' || to_char(add_months(to_date(YM,'YYYYMM'), +9),'YYYY') || '/3' end as FILTER_2YEAR_APR,
case when substring(YM,5,2) < 4 then 'Q1' when substring(YM,5,2) < 7 then 'Q2' when substring(YM,5,2) < 10 then 'Q3' else 'Q4' end as WS_DISP_QUARTER_JAN,
case when substring(YM,5,2) < 4 then 'Q4' when substring(YM,5,2) < 7 then 'Q1' when substring(YM,5,2) < 10 then 'Q2' else 'Q3' end as WS_DISP_QUARTER_APR,
case when substring(YM,5,2) < 7 then '1H' else '2H' end as WS_DISP_HALF_JAN,
case when substring(YM,5,2) >= 4 and substring(YM,5,2) < 10 then '1H' else '2H' end as WS_DISP_HALF_APR,
substring(YM,1,4) as WS_DISP_YEAR_JAN,
to_char(add_months(to_date(YM,'YYYYMM'), -3),'YYYY') as WS_DISP_YEAR_APR,
substring(YM,5,2) as WS_SORT_MONTH_JAN,
to_char(add_months(to_date(YM,'YYYYMM'), -3),'MM') as WS_SORT_MONTH_APR
from table1
)
select 1 demo from PP_WS_FLG;
create table schema2.tmp (
demo int
);
insert into schema2.tmp
select demo from
schema1.tmp_v;
YM 是格式为 YYYYMM 的字符串
您好,我能够解决问题,
schema1.tmp_v 查询使用视图来引用数据并创建视图。由于引用的视图遵循禁止的模式,因此产生了问题