的錯誤如下:創建DB2存儲過程Error..can人提供洞察
H1WICTDD.WICQ083A:44:非法符號 「」。這可能是 法律一些符號是:+ - (TRIM XMLSERIALIZE CAST XMLCAST CASE CURRENT_DATE SQLCODE = -104,SQLSTATE = 42601,DRIVER = 3.62.80
的SQL(我沒有得到任何語法警告之前嘗試部署):
CREATE PROCEDURE H1WICTDD.WICQ083a(IN parmCollection VARCHAR(8), IN parmAgencyID CHAR(3), IN parmSQLCODE INT)
VERSION V1
ISOLATION LEVEL CS
RESULT SETS 1
LANGUAGE SQL
QUALIFIER H1xxx
P1:BEGIN
DECLARE strAgencyID VARCHAR(3);
DECLARE dtDATE DATE;
DECLARE strServer VARCHAR(10);
DECLARE strUser VARCHAR(8);
DECLARE strLowAgencyID CHAR(3);
DECLARE c_result CURSOR WITH RETURN FOR RES_SET;
SET dtDate=(CURRENT DATE - 13 MONTHS);
SET strServer=CURRENT SERVER;
SET strUser=USER;
--SELECT CURRENT SERVER INTO strServer FROM SYSIBM.SYSDUMMY1;
--SELECT CURRENT SESSION_USER INTO strUser FROM SYSIBM.SYSDUMMY1;
IF strServer = 'HWDCH1xxx' THEN
SET strLowAgencyID ='100';
ELSE
SET strLowAgencyID ='101';
END IF;
SELECT GAGENCYID INTO strAgencyID
FROM VINFWICIDUSER
WHERE GUSERID = strUser
WITH UR;
--If strAgencyID of the USER equals the passed in parmAgency ID
--or strAgencyID has astriks (*) then the user has access to statewide
--Reports. So test taht first. If passes that test, then see if they
--want state or agency only
IF strAgencyID=parmAgencyID OR strAgencyID Like '*%' THEN
IF parmAgencyID=’ALL’ THEN
--STATEWIDE
SELECT
A.GAGENCYID,
B.GAGENCYNAME,
A.GPARTICIPMONTH,
C.GCASELOADCNT,
A.GPARTICIPATION,
(C.GCASELOADCNT - A.GPARTICIPATION) AS GCLESSP,
COALESCE(SUM(D.GCNTTOTAL),0) AS GUNISSUEDCNT
FROM
VINFPARTICPSUMM A
INNER JOIN VINFAGENCY B
ON B.GAGENCYID = A.GAGENCYID
INNER JOIN VINFCASELOAD C
ON C.GAGENCYID = A.GAGENCYID
LEFT OUTER JOIN VINFUNISSUEDRX D
ON D.GAGENCYID = A.GAGENCYID
AND CONCAT(SUBSTR(CHAR(A.GPARTICIPMONTH,ISO),1,4),
SUBSTR(CHAR(A.GPARTICIPMONTH,ISO),6,2))
= D.GRXMONTHYEAR
WHERE
A.GPARTICIPMONTH >= dtDATE
AND A.GAGENCYID BETWEEN strLowAgencyID AND '399'
AND C.GEFFECTIVEDATE =
(SELECT MAX(E.GEFFECTIVEDATE)
FROM VINFCASELOAD E
WHERE E.GAGENCYID = A.GAGENCYID
AND E.GEFFECTIVEDATE <= A.GPARTICIPMONTH)
GROUP BY A.GAGENCYID,
B.GAGENCYNAME,
A.GPARTICIPMONTH,
A.GPARTICIPATION,
C.GCASELOADCNT
WITH UR;
ELSE
--AGENCY
SELECT
A.GAGENCYID,
B.GAGENCYNAME,
A.GPARTICIPMONTH,
C.GCASELOADCNT,
A.GPARTICIPATION,
(C.GCASELOADCNT - A.GPARTICIPATION) AS GCLESSP,
COALESCE(SUM(D.GCNTTOTAL),0) AS GUNISSUEDCNT
FROM
VINFPARTICPSUMM A
INNER JOIN VINFAGENCY B
ON B.GAGENCYID = A.GAGENCYID
INNER JOIN VINFCASELOAD C
ON C.GAGENCYID = A.GAGENCYID
LEFT OUTER JOIN VINFUNISSUEDRX D
ON D.GAGENCYID = A.GAGENCYID
AND CONCAT(SUBSTR(CHAR(A.GPARTICIPMONTH,ISO),1,4),
SUBSTR(CHAR(A.GPARTICIPMONTH,ISO),6,2))
= D.GRXMONTHYEAR
WHERE
A.GPARTICIPMONTH >= dtDATE
AND A.GAGENCYID = parmAgencyID
AND C.GEFFECTIVEDATE =
(SELECT MAX(E.GEFFECTIVEDATE)
FROM VINFCASELOAD E
WHERE E.GAGENCYID = A.GAGENCYID
AND E.GEFFECTIVEDATE <= A.GPARTICIPMONTH)
GROUP BY A.GAGENCYID,
B.GAGENCYNAME,
A.GPARTICIPMONTH,
A.GPARTICIPATION,
C.GCASELOADCNT
WITH UR;
END IF;
END IF;
OPEN c_result;
--=============================================================
--Handle Errors and Log them
--==============================================================
--EXEC Stored Proc WICQ00R (STORPROC_NAME, RETURN_CODE, MISC, strUser, CURRENT DATETIME)
END P1
在一個複合語句中,你只能'SELECT'' INTO'(或聲明一個遊標)。 – mustaccio
這似乎是這種情況。謝謝 – KML
編輯顯示錯誤。 – ManishChristian