0

当调用以下存储过程时,我得到 table in use 异常。

下面是存储过程的代码,

CREATE PROCEDURE SP_BATCHFILE_REPORT_GET001 (
    IN countryCode CHAR(2),
    IN reportFileID BIGINT
    )
RESULT SETS 1
LANGUAGE SQL
SET OPTION COMMIT=*CS
P1: BEGIN
DECLARE cc CHAR(2);
DECLARE fid BIGINT;

-- Declare cursor
DECLARE cursor1 CURSOR FOR
    SELECT * FROM CPS_FILE
        WHERE COUNTRYCODE = cc
            AND ReportFileID = fid
        AND ReportGenerated = 'P'
        AND Accepted <> '';

SET cc = countryCode;
SET fid = reportFileID;

UPDATE cps_file SET ReportGenerated = 'P'
        WHERE COUNTRYCODE = cc
            AND ReportFileID = fid
        AND ReportGenerated <> 'Y'
        AND Accepted <> '';

-- Cursor left open for client application
OPEN cursor1;
END P1 @

我使用 DB2 作为数据库,同时没有其他进程在运行,它可以访问存储过程中使用的表。

我收到以下错误,Row or object CPS_FILE in CPSDATA type *FILE in use。

请指教。

4

0 回答 0