尝试创建触发器时,IBM DB2 SQLCODE -1424,SQLSTATE 54040

时间:2014-11-11 14:00:20

标签: stored-procedures triggers db2

我试图创建以下触发器(DB2 / LINUXX8664 9.7.2在Ubuntu 10.04.2 LTS上运行),但我总是这样:

Error report:
DB2 SQL error: SQLCODE: -1424, SQLSTATE: 54040, SQLERRMC: 2

根据IBM DB2文档:

Too many references to transition variables and transition table columns or the row length for these references is too long. Reason code=rc.

http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.5.0/com.ibm.db2.luw.messages.sql.doc/doc/msql01424n.html

我真的不明白这个解释。这里存储过程和触发器:

CREATE PROCEDURE SP_INSERT_UPDATE_REPNUM (
   IN RECNUM           INTEGER,
   IN CUSTOMER_ID      INTEGER,
   IN Q_CODE           VARCHAR(14),
   IN S_CODE           VARCHAR(14),
     IN REP_STATUS       INTEGER,
     IN P_CODE           INTEGER,
     IN REPNUMRG_ID      INTEGER,
     IN VOLG_LET         VARCHAR(1),
     IN REP_DATUM        DATE,
     IN REP_INI          VARCHAR(2),
     IN INGEBOEKT_DATUM  DATE,
     IN INGEBOEKT_INI    VARCHAR(2),
     IN WIJZIGING_DATUM  DATE,
     IN WIJZIGING_INI    VARCHAR(2),
     IN OMSCR_STORING    VARCHAR(5),
     IN OMSCR_WERKZ      VARCHAR(5),
     IN OMSCR_OPMERKING  VARCHAR(5),
     IN OMSCR_GEBREK     VARCHAR(5),
     IN OMSCR_MAT        VARCHAR(5),
     IN REP_TIJD         FLOAT,
     IN REP_GEDAAN       CHAR(1),
     IN ACTION           CHAR(1)
)
SPECIFIC SP_INSERT_UPDATE_REPNUM
DYNAMIC RESULT SETS 0
DETERMINISTIC
LANGUAGE JAVA
PARAMETER STYLE JAVA
NO DBINFO
NOT FENCED
THREADSAFE
MODIFIES SQL DATA
PROGRAM TYPE SUB
EXTERNAL NAME 'RepairMigration!insertServiceReport'

这里是触发器:

CREATE TRIGGER INSERT_REPNUM
  AFTER INSERT ON REPNUM
  REFERENCING NEW ROW AS NROW
    FOR EACH ROW MODE DB2SQL
BEGIN 
  CALL SP_INSERT_UPDATE_REPNUM(
    NROW.RECNUM,
    NROW.CUSTOMER_ID,
    NROW.Q_CODE,
    NROW.S_CODE,
    NROW.REP_STATUS,
    NROW.P_CODE,
    NROW.REPNUMRG_ID,
    NROW.VOLG_LET,
    NROW.REP_DATUM,
    NROW.REP_INI,
    NROW.INGEBOEKT_DATUM,
    NROW.INGEBOEKT_INI,
    NROW.WIJZIGING_DATUM,
    NROW.WIJZIGING_INI,
    NROW.OMSCR_STORING,
    NROW.OMSCR_WERKZ,
    NROW.OMSCR_OPMERKING,
    NROW.OMSCR_GEBREK,
    NROW.OMSCR_MAT,
    NROW.REP_TIJD,
    NROW.REP_GEDAAN,
    'I'
  );
END

表结构是第一个:

RECNUM              INTEGER 4   0   N   
Q_CODE              CHARACTER   14  0   N   ''
U_Q_CODE            CHARACTER   14  0   N   
S_CODE              CHARACTER   14  0   N   ''
U_S_CODE            CHARACTER   14  0   N   
VOLG_LET            CHARACTER   1   0   N   ''
U_VOLG_LET          CHARACTER   1   0   N   
REP_DATUM           DATE    4   0   N   '0001-01-01'
REP_INI             CHARACTER   2   0   N   ''
P_CODE              INTEGER 4   0   N   0
CUSTOMER_ID         INTEGER 4   0   N   0
REPNUMHD_ID         INTEGER 4   0   N   0
REPNUMRG_ID         INTEGER 4   0   N   0
REP_STATUS          SMALLINT    2   0   N   0
KONTAKT_PER         CHARACTER   25  0   N   ''
KONTAKT_TEL         CHARACTER   20  0   N   ''
OMSCR_STORING       VARCHAR 512 0   N   ''
OMSCR_WERKZ         VARCHAR 2000    0   N   ''
OMSCR_MAT           VARCHAR 512 0   N   ''
WIJZIGING_DATUM     DATE    4   0   N   '0001-01-01'
WIJZIGING_INI       CHARACTER   2   0   N   ''
INGEBOEKT_DATUM     DATE    4   0   N   '0001-01-01'
INGEBOEKT_INI       CHARACTER   2   0   N   ''
REP_GEDAAN          CHARACTER   1   0   N   ''
U_REP_GEDAAN        CHARACTER   1   0   N   
STATUS              SMALLINT    2   0   N   0
UW_OPDRACHT         CHARACTER   20  0   N   ''
REP_UREN            SMALLINT    2   0   N   0
REP_MINUTEN         SMALLINT    2   0   N   0
OMSCR_OPMERKING     VARCHAR 1008    0   N   ''
OMSCR_GEBREK        VARCHAR 512 0   N   ''
SERVICE_NUMMER      INTEGER 4   0   N   0
PRIJS_OPGAVE        CHARACTER   1   0   N   ''
CURRENCY            SMALLINT    2   0   N   0
REP_TIJD            INTEGER 4   0   N   0

尝试执行触发器后,我收到错误消息。我该如何解决这个问题?

更新

看起来我需要创建一个临时表空间。列出我的所有表空间,我得到了一些超过4k的表空间,例如这个:

 Tablespace ID                        = 7
 Name                                 = TEMPSPACE1234
 Type                                 = Database managed space
 Contents                             = All permanent data. Regular table space.
 State                                = 0x0000
   Detailed explanation:
     Normal
 Total pages                          = 1024
 Useable pages                        = 1008
 Used pages                           = 432
 Free pages                           = 576
 High water mark (pages)              = 528
 Page size (bytes)                    = 32768
 Extent size (pages)                  = 16
 Prefetch size (pages)                = 16
 Number of containers                 = 1

1 个答案:

答案 0 :(得分:1)

1)创建32K缓冲池

示例:

CREATE BUFFERPOOL "BUFFERPOOLLARGE" IMMEDIATE
ALL DBPARTITIONNUMS  SIZE AUTOMATIC
NUMBLOCKPAGES 0
PAGESIZE 32 K;

2)创建一个32K SYSTEM TEMPORARY TABLESPACE

示例:

CREATE SYSTEM TEMPORARY TABLESPACE "TEMPSPACELARGE"
IN DATABASE PARTITION GROUP "IBMTEMPGROUP"
PAGESIZE 32 K
MANAGED BY AUTOMATIC STORAGE
EXTENTSIZE 32
BUFFERPOOL "BUFFERPOOLLARGE"
OVERHEAD INHERIT
TRANSFERRATE INHERIT
USING STOGROUP "IBMSTOGROUP"
FILE SYSTEM CACHING;

3)再次运行CREATE PROCEDURE Script。

OBS:在示例中,我使用了DB2 automatic TABLESPACE。