程序不运行
Procedure is not running
我正在 运行ning 下面查询,给出错误。需要做什么才能获得请求的结果?
create or replace PROCEDURE data_cleanup_29th_nov_2020
IS
BEGIN
EXECUTE IMMEDIATE 'create table TEMP_ID_STAT_TIME_FRM_JOB_DOC as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 and status=''Sent''';
execute immediate 'delete from HUB_SIG where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
execute immediate 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
END;
commit;
在 运行ning 程序出现以下错误后
BEGIN
data_cleanup_29th_nov_2020();
--rollback;
END;
ORA-00955: name is already used by an existing object
ORA-06512: at "HUB.DATA_CLEANUP_29TH_NOV_2020", line 7
ORA-06512: at line 2
00955. 00000 - "name is already used by an existing object
尝试了以下查询:
CREATE OR REPLACE PROCEDURE ATAS_CLEANUP_NOV_2020 IS
BEGIN
EXECUTE IMMEDIATE 'create table TEMP_ID_STAT_TIME_FRM_JOB_DOC as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 and status=''Sent''';
EXECUTE IMMEDIATE 'delete from HUB_SIGNATURE_DETAILS where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
--EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE TEMP_JOB_ID_FROM_JOB_DOC_1119';
EXCEPTION
WHEN OTHER THEN
NULL;
END;
EXECUTE IMMEDIATE 'ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
END;
出现以下错误:
Error(14,5): PL/SQL: Statement ignored
Error(17,14): PLS-00201: identifier 'OTHER' must be declared
试过这个并且成功:
CREATE OR REPLACE PROCEDURE ATAS_LATEST_DATA_cleanup_nov IS
BEGIN
EXECUTE IMMEDIATE 'delete from HUB_SIG where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
--EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
--BEGIN
-- EXECUTE IMMEDIATE 'DROP TABLE TEMP_JOB_ID_FROM_JOB_DOC_1119';
--EXCEPTION
-- WHEN OTHER THEN
-- NULL;
-- END;
EXECUTE IMMEDIATE 'ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
END;
COMMIT;
BEGIN
ATAS_LATEST_DATA_cleanup_nov();
--rollback;
END;
匿名区块完成
在过程外创建临时 table。
create table TEMP_JOB_ID_FROM_JOB_DOC_1119 as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 和状态='Sent'
并且在 运行 数据出现在 TEMP_JOB_ID_FROM_JOB_DOC_1119
之后,现在使用临时 table 内部程序
现在我们必须实现获取日期作为输入并传递它
当重命名 table (RENAME TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119 )
并在 DBMS_SCHEDULER 到 运行 每晚太平洋标准时间晚上 10 点安排此程序。
我们该怎么做?
请检查“create table TEMP_ID_STAT_TIME_FRM_JOB_DOC”这个 create table 语句,因为“TEMP_ID_STAT_TIME_FRM_JOB_DOC”已经存在于您的系统中。
你的rename table
命令有误。
应该是:
ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_1119;
此外,您可以执行该过程一次,如果您要再次执行它,那么它会在重命名命令中抛出错误。
现在,查看数据库中是否已有 table 可用。如果是,则在再次调用以下过程之前将其删除。
所以试试这个代码:
CREATE OR REPLACE PROCEDURE DATA_CLEANUP_29TH_NOV_2020
(P_IN_DATE IN DATE)
IS
BEGIN
EXECUTE IMMEDIATE 'create table TEMP_ID_STAT_TIME_FRM_JOB_DOC as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 and status=''Sent''';
EXECUTE IMMEDIATE 'delete from HUB_SIG where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
--EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE TEMP_JOB_ID_FROM_JOB_DOC_1119';
EXCEPTION
WHEN OTHER THEN
NULL;
END;
EXECUTE IMMEDIATE 'ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_' || TO_CHAR(P_IN_DATE, 'MMYY');
END;
/
避免动态查询总是好的做法。
您可以在此过程之外创建一个 table 并用它来存储临时数据。或者您可以使用全局临时 table.
我正在 运行ning 下面查询,给出错误。需要做什么才能获得请求的结果?
create or replace PROCEDURE data_cleanup_29th_nov_2020
IS
BEGIN
EXECUTE IMMEDIATE 'create table TEMP_ID_STAT_TIME_FRM_JOB_DOC as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 and status=''Sent''';
execute immediate 'delete from HUB_SIG where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
execute immediate 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
END;
commit;
在 运行ning 程序出现以下错误后
BEGIN
data_cleanup_29th_nov_2020();
--rollback;
END;
ORA-00955: name is already used by an existing object ORA-06512: at "HUB.DATA_CLEANUP_29TH_NOV_2020", line 7 ORA-06512: at line 2 00955. 00000 - "name is already used by an existing object
尝试了以下查询:
CREATE OR REPLACE PROCEDURE ATAS_CLEANUP_NOV_2020 IS
BEGIN
EXECUTE IMMEDIATE 'create table TEMP_ID_STAT_TIME_FRM_JOB_DOC as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 and status=''Sent''';
EXECUTE IMMEDIATE 'delete from HUB_SIGNATURE_DETAILS where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
--EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE TEMP_JOB_ID_FROM_JOB_DOC_1119';
EXCEPTION
WHEN OTHER THEN
NULL;
END;
EXECUTE IMMEDIATE 'ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
END;
出现以下错误:
Error(14,5): PL/SQL: Statement ignored Error(17,14): PLS-00201: identifier 'OTHER' must be declared
试过这个并且成功:
CREATE OR REPLACE PROCEDURE ATAS_LATEST_DATA_cleanup_nov IS
BEGIN
EXECUTE IMMEDIATE 'delete from HUB_SIG where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
--EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
--BEGIN
-- EXECUTE IMMEDIATE 'DROP TABLE TEMP_JOB_ID_FROM_JOB_DOC_1119';
--EXCEPTION
-- WHEN OTHER THEN
-- NULL;
-- END;
EXECUTE IMMEDIATE 'ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
END;
COMMIT;
BEGIN
ATAS_LATEST_DATA_cleanup_nov();
--rollback;
END;
匿名区块完成
在过程外创建临时 table。 create table TEMP_JOB_ID_FROM_JOB_DOC_1119 as select JOB_ID, last_update_time_utc, status from J_DOC where LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 和状态='Sent'
并且在 运行 数据出现在 TEMP_JOB_ID_FROM_JOB_DOC_1119
之后,现在使用临时 table 内部程序现在我们必须实现获取日期作为输入并传递它 当重命名 table (RENAME TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119 )
并在 DBMS_SCHEDULER 到 运行 每晚太平洋标准时间晚上 10 点安排此程序。 我们该怎么做?
请检查“create table TEMP_ID_STAT_TIME_FRM_JOB_DOC”这个 create table 语句,因为“TEMP_ID_STAT_TIME_FRM_JOB_DOC”已经存在于您的系统中。
你的rename table
命令有误。
应该是:
ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_1119;
此外,您可以执行该过程一次,如果您要再次执行它,那么它会在重命名命令中抛出错误。
现在,查看数据库中是否已有 table 可用。如果是,则在再次调用以下过程之前将其删除。
所以试试这个代码:
CREATE OR REPLACE PROCEDURE DATA_CLEANUP_29TH_NOV_2020
(P_IN_DATE IN DATE)
IS
BEGIN
EXECUTE IMMEDIATE 'create table TEMP_ID_STAT_TIME_FRM_JOB_DOC as select JOB_ID, last_update_time_utc, status from J_DOC where
LAST_UPDATE_TIME_UTC <= TRUNC(SYSDATE) - 30 and status=''Sent''';
EXECUTE IMMEDIATE 'delete from HUB_SIG where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
EXECUTE IMMEDIATE 'delete from J_DOC
where JOB_id IN ( SELECT JOB_ID
FROM TEMP_ID_STAT_TIME_FRM_JOB_DOC)';
--EXECUTE IMMEDIATE 'RENAME TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC TO TEMP_JOB_ID_FROM_JOB_DOC_1119';
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE TEMP_JOB_ID_FROM_JOB_DOC_1119';
EXCEPTION
WHEN OTHER THEN
NULL;
END;
EXECUTE IMMEDIATE 'ALTER TABLE TEMP_ID_STAT_TIME_FRM_JOB_DOC RENAME TO TEMP_JOB_ID_FROM_JOB_DOC_' || TO_CHAR(P_IN_DATE, 'MMYY');
END;
/
避免动态查询总是好的做法。
您可以在此过程之外创建一个 table 并用它来存储临时数据。或者您可以使用全局临时 table.