我有一个DB2存储过程,它在数据库中插入一行。存储过程如下:
CREATE PROCEDURE ZSPPQINSERTUSERIDBA (
IN P_USERID CHAR(10),
IN P_BUSINESSAREA CHAR(10),
IN P_SELECTEDIND CHAR(1),
IN P_DEFAULTIND CHAR(1),
IN P_LEGACYSYSTEM CHAR(10),
IN P_LEGACYLOGIN CHAR(16),
IN P_LEGACYPASSWORD CHAR(16),
IN P_OTHERLOGIN CHAR(10),
IN P_OTHERPASSWORD CHAR(10),
IN P_ADDSECURLOGIN CHAR(10),
IN P_ADDSECURPASSWORD CHAR(10),
IN P_LASTUPDATEUSERID CHAR(10),
IN P_LASTUPDATE TIMESTAMP)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC ZSPPQINSERTUSERIDBA
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
SET OPTION ALWBLK = *ALLREAD ,
ALWCPYDTA = *OPTIMIZE ,
COMMIT = *CS ,
CLOSQLCSR = *ENDMOD ,
DECRESULT = (31, 31, 00) ,
DFTRDBCOL = *NONE ,
DYNDFTCOL = *NO ,
DYNUSRPRF = *USER ,
RDBCNNMTH = *RUW ,
SRTSEQ = *HEX
P1 : BEGIN
DECLARE TOTALCNT INTEGER DEFAULT 0 ;
DECLARE C1 CURSOR WITH RETURN FOR
SELECT Count (*) FROM USERBUSINESSAREA
WHERE USERID = P_USERID
AND BUSINESSAREA = P_BUSINESSAREA;
OPEN C1;
FETCH C1 INTO TOTALCNT;
CLOSE C1;
IF ( TOTALCNT = 0) THEN
INSERT
INTO USERBUSINESSAREA
(
USERID,
BUSINESSAREA,
SELECTEDIND,
DEFAULTIND,
LEGACYSYSTEM,
LEGACYLOGIN,
LEGACYPASSWORD,
OTHERLOGIN,
OTHERPASSWORD,
ADDSECURLOGIN,
ADDSECURPASSWORD,
LASTUPDATEUSERID,
LASTUPDATE
)
VALUES (P_USERID,
P_BUSINESSAREA,
P_SELECTEDIND,
P_DEFAULTIND,
P_LEGACYSYSTEM,
P_LEGACYLOGIN,
P_LEGACYPASSWORD,
P_OTHERLOGIN,
P_OTHERPASSWORD,
P_ADDSECURLOGIN,
P_ADDSECURPASSWORD,
P_LASTUPDATEUSERID,
P_LASTUPDATE);
END IF;
END P1;
当我尝试从Java / Spring-Integration层执行上述存储过程时,不返回任何结果集。我需要对上面的存储过程进行哪些更改才能返回结果集?
答案 0 :(得分:0)
你想要什么回来?
我不知道你的期望:
答案 1 :(得分:0)
以下修改过的存储过程对我有用(刚刚将WITH RETURN FOR
更改为RETURN TO CALLER FOR
):
CREATE PROCEDURE ZSPPQINSERTUSERIDBA (
IN P_USERID CHAR(10),
IN P_BUSINESSAREA CHAR(10),
IN P_SELECTEDIND CHAR(1),
IN P_DEFAULTIND CHAR(1),
IN P_LEGACYSYSTEM CHAR(10),
IN P_LEGACYLOGIN CHAR(16),
IN P_LEGACYPASSWORD CHAR(16),
IN P_OTHERLOGIN CHAR(10),
IN P_OTHERPASSWORD CHAR(10),
IN P_ADDSECURLOGIN CHAR(10),
IN P_ADDSECURPASSWORD CHAR(10),
IN P_LASTUPDATEUSERID CHAR(10),
IN P_LASTUPDATE TIMESTAMP)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC ZSPPQINSERTUSERIDBA
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
SET OPTION ALWBLK = *ALLREAD ,
ALWCPYDTA = *OPTIMIZE ,
COMMIT = *CS ,
CLOSQLCSR = *ENDMOD ,
DECRESULT = (31, 31, 00) ,
DFTRDBCOL = *NONE ,
DYNDFTCOL = *NO ,
DYNUSRPRF = *USER ,
RDBCNNMTH = *RUW ,
SRTSEQ = *HEX
P1 : BEGIN
DECLARE TOTALCNT INTEGER DEFAULT 0 ;
DECLARE C1 CURSOR WITH RETURN TO CALLER FOR
SELECT Count (*) FROM USERBUSINESSAREA
WHERE USERID = P_USERID
AND BUSINESSAREA = P_BUSINESSAREA;
OPEN C1;
FETCH C1 INTO TOTALCNT;
IF ( TOTALCNT = 0) THEN
INSERT
INTO USERBUSINESSAREA
(
USERID,
BUSINESSAREA,
SELECTEDIND,
DEFAULTIND,
LEGACYSYSTEM,
LEGACYLOGIN,
LEGACYPASSWORD,
OTHERLOGIN,
OTHERPASSWORD,
ADDSECURLOGIN,
ADDSECURPASSWORD,
LASTUPDATEUSERID,
LASTUPDATE
)
VALUES (P_USERID,
P_BUSINESSAREA,
P_SELECTEDIND,
P_DEFAULTIND,
P_LEGACYSYSTEM,
P_LEGACYLOGIN,
P_LEGACYPASSWORD,
P_OTHERLOGIN,
P_OTHERPASSWORD,
P_ADDSECURLOGIN,
P_ADDSECURPASSWORD,
P_LASTUPDATEUSERID,
P_LASTUPDATE);
END IF;
END P1;