我创建如下存储过程:
replace PROCEDURE mydb.sp_Insert_Values (
IN lastExecDate timestamp
)
SQL SECURITY CREATOR
BEGIN
CREATE MULTISET VOLATILE TABLE vt_ref_table_1
(
Ref_Id integer,
Ref_Unit_Type varchar(50)
) ON COMMIT PRESERVE ROWS;
insert into mydb.vt_ref_table_1
select Ref_Id, Ref_Unit_Type
from mydb.ref_table_1;
INSERT INTO mydb.Time_Series_Table
select
t1.TD_TIMECODE
, t1.Time_Series_Meas
, t1.Time_Series_Curve_Type_CD
, t1.Ref_Unit_Type
, t1.Ref_Id
, t1.created_on
from
(
select
meas_ts as TD_TIMECODE
, ref_table_1.Ref_Id as Ref_Id
, meas as Time_Series_Meas,
, Time_Series_Curve_Type_CD
, Ref_Unit_Type
, current_timestamp as created_on
from mydb_stg.Time_Series_Table_Stg as stg
left join mydb.ref_table_1 as ref_table_1
on ref_table_1.Ref_Id = stg.Ref_Id
where stg.created_on >= :lastExecDate
) as t1
left join mydb.Time_Series_Table as t2
on t1.TD_TIMECODE=t2.TD_TIMECODE
and t1.Time_Series_Curve_Type_CD = t2.Time_Series_Curve_Type_CD
and t1.Ref_Id=t2.Ref_Id
where t2.Ref_Id is null
;
END;
它可以编译,但是当我调用它时会抛出此错误:
在DDL语句之后,只有COMMIT WORK或null语句是合法的。
我知道该错误与易失性表有关,但我不知道如何纠正它。
为什么我需要可变表:
参考表具有行级安全性约束。如果直接使用它,则会出现另一个错误:
执行了多表操作,并且这些表没有 相同的安全约束。
Teradata版本:16.20
模式:ANSI