0

我正在从 BW 调用过程托盘调用 DB2 存储过程。

当我在数据库中测试这个 proc 时,它正在正确执行。但是当我通过 BW 调用时,它会抛出异常

JDBC 错误报告:(SQLState = 57014) - com.ibm.db2.jcc.am.SqlException: DB2 SQL 错误: SQLCODE=-952, SQLSTATE=57014, SQLERRMC=null,

我存储过程的代码如下

CREATE OR REPLACE PROCEDURE TABLE1_PURGE_PROC_V1 (IN v_REF_VERSION VARCHAR(3), OUT o_DELTETE_STATUS VARCHAR(7))
    P1: BEGIN

    --DECLARE v_TABLE_NAME VARCHAR(30);
    DECLARE v_WHERE_CONDITION VARCHAR(1024);
    DECLARE V_COUNT_QUERY VARCHAR(1024);
    DECLARE v_COMMIT_COUNT INTEGER;

    SET v_WHERE_CONDITION='REF_VERSION ='||v_REF_VERSION;
    SET v_COMMIT_COUNT=10000;


    CALL SCHEMA.DELETE_WITH_COMMIT_COUNT('SCHEMA.TABLE1',v_COMMIT_COUNT,v_WHERE_CONDITION);
    CALL SCHEMA.DELETE_WITH_COMMIT_COUNT('SCHEMA.TABLE2',v_COMMIT_COUNT,v_WHERE_CONDITION);
    CALL SCHEMA.DELETE_WITH_COMMIT_COUNT('SCHEMA.TABLE3',v_COMMIT_COUNT,v_WHERE_CONDITION);
    CALL SCHEMA.DELETE_WITH_COMMIT_COUNT('SCHEMA.TABLE4',v_COMMIT_COUNT,v_WHERE_CONDITION);


    INSERT INTO SCHEMA.DEBUG_LOG(PROC_NAME,LOG_TIME,MESSAGE) VALUES('TABLE1_PURGE_PROC_V1',CURRENT_TIMESTAMP,'ALL TABLE1 RELATED TABLES INVALID DATA DELETED FOR VERSION-'||v_REF_VERSION);

    SET o_DELTETE_STATUS ='SUCCESS';
    END P1 

    ####################################### PROC 2 ###########################################################
    CREATE OR REPLACE PROCEDURE DELETE_WITH_COMMIT_COUNT(IN v_TABLE_NAME VARCHAR(24), IN v_COMMIT_COUNT INTEGER, IN v_WHERE_CONDITION VARCHAR(1024))
        NOT DETERMINISTIC
        LANGUAGE SQL
    P1: BEGIN
     -- DECLARE Statements
        DECLARE SQLCODE INTEGER;
        DECLARE v_DELETE_QUERY VARCHAR(1024);
        DECLARE v_DELETE_STATEMENT STATEMENT;


        SET v_DELETE_QUERY = 'DELETE FROM (SELECT 1 FROM ' || v_TABLE_NAME || ' WHERE ' || v_WHERE_CONDITION
            || ' FETCH FIRST ' || RTRIM(CHAR(v_COMMIT_COUNT)) || ' ROWS ONLY) AS DELETE_TABLE';

        PREPARE v_DELETE_STATEMENT FROM v_DELETE_QUERY;


        DEL_LOOP:
            LOOP
                EXECUTE v_DELETE_STATEMENT;
                IF SQLCODE = 100 THEN
                    INSERT INTO TEP.DEBUG_LOG(PROC_NAME,LOG_TIME,MESSAGE) VALUES('DELETE_WITH_COMMIT_COUNT',CURRENT_TIMESTAMP,'ALL DATA DELETED FROM'||v_TABLE_NAME||'QUERY USED IS'||v_DELETE_QUERY);
                    LEAVE DEL_LOOP; 
                END IF;
                COMMIT;
            END LOOP;   
        COMMIT;
    END P1 

据我研究,据说这是 DB2 中的中断代码。如何在 DB2 中处理这个问题

4

1 回答 1

2

我将 Tibco 超时添加到现在工作的 6 分钟。
从 12 个表中删除 200 万条数据
谢谢大家的帮助

于 2014-09-23T20:56:13.617 回答