我创建了一个执行这些步骤的过程:
当我添加最后一步(数字3)时,我收到下面屏幕截图中显示的错误。你能帮我理解我应该做些什么来使这项工作吗?
REPLACE PROCEDURE SP_New_Procedure ()
DYNAMIC RESULT SETS 1
SQL SECURITY OWNER
BEGIN
------------Deleting last 8 days of data -------------------------------
DELETE FROM History_Table
WHERE Date BETWEEN CURRENT_DATE -INTERVAL '8' DAY(FORMAT 'YYYYMMdd')
AND CURRENT_DATE -INTERVAL '1' DAY(FORMAT 'YYYYMMdd');
------------Inserting updated last 8 days of data------------------------
INSERT INTO History_Table
SELECT
FinalTable.*
FROM
Data_Query AS FinalTable;
------------Return All values from updated History_Table-------------------
SELECT * FROM History_Table;
END;
谢谢!
丹尼尔
答案 0 :(得分:0)
Teradata遵循标准SQL,您必须使用游标语法(它不是应该避免处理数据的实际游标)来返回结果集。没有游标,您只能返回单行INTO变量。
REPLACE PROCEDURE SP_New_Procedure ()
DYNAMIC RESULT SETS 1
SQL SECURITY OWNER
BEGIN
------------Deleting last 8 days of data -------------------------------
DELETE FROM History_Table
WHERE Date BETWEEN CURRENT_DATE - 1
AND CURRENT_DATE - 8
------------Inserting updated last 8 days of data------------------------
INSERT INTO History_Table
SELECT
FinalTable.*
FROM
Data_Query AS FinalTable;
------------Return All values from updated History_Table-------------------
BEGIN
DECLARE cur CURSOR WITH RETURN ONLY FOR
SELECT * FROM History_Table;
OPEN cur; -- don't close it, otherwise there's no result
END;
END;
希望History_Table
被该日期列分区。