我必须编写一个包含多个插入的脚本。我也这样做了,并在 Toad 中运行脚本。脚本在大约 35 - 40 分钟内完成。
然后我将该脚本应用到 autosys,并再次运行它(这就是它应该使用的方式)。而这一次,它持续运行了1.5个多小时。
我必须手动终止 Oracle 中的活动会话。
请查看我的脚本并告诉我,为什么它没有在预期的 40 分钟时间内完成并继续运行超过 1.5 小时。
编辑:想提一下,在 Autosys 调用的父脚本中调用了“commit”等常用命令。我的脚本是在父脚本中调用的子脚本之一。
-- Begining of Consolidated queries for Slow performing Talend Jobs
SET SERVEROUTPUT ON;
spool Consolidated.log;
WHENEVER SQLERROR EXIT SQL.SQLCODE;
SET DEFINE OFF;
ALTER SESSION SET GLOBAL_NAMES=FALSE;
DECLARE
ExtractType NUMBER(9);
RecordsExtracted NUMBER(9);
CurStatus NUMBER(9);
StartDate date;
ErrorMessage NVARCHAR2(1000);
LastExtrctTimestamp DATE;
-- TABLE1
BEGIN
StartDate := sysdate;
ExtractType := 44;
DELETE FROM Table1;
INSERT INTO Table1
SELECT Statement....;
RecordsExtracted := SQL%RowCount;
DBMS_OUTPUT.put_line('Table1 Records Extracted:' || RecordsExtracted);
-- On Success
CurStatus := 2;
ErrorMessage := 'Table1 Complete';
INSERT INTO ExtractRecords(ExtractType, RecordsExtracted, Status, ExtractTimestamp, StartDate, EndDate, ErrorMessage)
VALUES (ExtractType, RecordsExtracted, CurStatus, SysDate, StartDate, SysDate, ErrorMessage);
INSERT INTO LoadRecords (LoadType,Status,LoadTimestamp,StartDate,EndDate)
VALUES (ExtractType, CurStatus, SysDate, StartDate, SysDate);
-- TABLE2 RESULTS
StartDate := sysdate;
ExtractType := 78;
DELETE FROM Table2;
INSERT INTO Table2
SELECT Statement....;
RecordsExtracted := SQL%RowCount;
DBMS_OUTPUT.put_line('Table2 Records Extracted:' || RecordsExtracted);
-- On Success
CurStatus := 2;
ErrorMessage := 'Table2 Complete';
INSERT INTO ExtractRecords(ExtractType, RecordsExtracted, Status, ExtractTimestamp, StartDate, EndDate, ErrorMessage)
VALUES (ExtractType, RecordsExtracted, CurStatus, SysDate, StartDate, SysDate, ErrorMessage);
INSERT INTO LoadRecords (LoadType,Status,LoadTimestamp,StartDate,EndDate)
VALUES (ExtractType, CurStatus, SysDate, StartDate, SysDate);
-- TABLE3
StartDate := sysdate;
ExtractType := 81;
DELETE FROM Table3;
INSERT INTO Table3
SELECT Statement....;
RecordsExtracted := SQL%RowCount;
DBMS_OUTPUT.put_line('Table3 Records Extracted:' || RecordsExtracted);
-- On Success
CurStatus := 2;
ErrorMessage := 'Table3 Complete';
INSERT INTO ExtractRecords(ExtractType, RecordsExtracted, Status, ExtractTimestamp, StartDate, EndDate, ErrorMessage)
VALUES (ExtractType, RecordsExtracted, CurStatus, SysDate, StartDate, SysDate, ErrorMessage);
INSERT INTO LoadRecords (LoadType,Status,LoadTimestamp,StartDate,EndDate)
VALUES (ExtractType, CurStatus, SysDate, StartDate, SysDate);
-- TABLE4
StartDate := sysdate;
ExtractType := 57;
DELETE FROM Table4;
INSERT INTO Table4
SELECT Statement....;
RecordsExtracted := SQL%RowCount;
DBMS_OUTPUT.put_line('Table4 Records Extracted:' || RecordsExtracted);
-- On Success
CurStatus := 2;
ErrorMessage := 'Table4 Complete';
INSERT INTO ExtractRecords(ExtractType, RecordsExtracted, Status, ExtractTimestamp, StartDate, EndDate, ErrorMessage)
VALUES (ExtractType, RecordsExtracted, CurStatus, SysDate, StartDate, SysDate, ErrorMessage);
INSERT INTO LoadRecords (LoadType,Status,LoadTimestamp,StartDate,EndDate)
VALUES (ExtractType, CurStatus, SysDate, StartDate, SysDate);
END;
spool off;
exit;
/