错误如下:
H1WICTDD.WICQ083A:44:ILLEGAL SYMBOL“”。一些可能的符号 法律是:+ - (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
答案 0 :(得分:0)
错误消息表示第44行,即
IF parmAgencyID=’ALL’ THEN
我猜测智能引用并非意图。
答案 1 :(得分:0)
谢谢eveyone。它出现在DB2中,我不能让条件逻辑指示要使用的SELECT语句。我必须在每个SELECT语句之前声明一个CURSOR,然后将条件逻辑放在底部并打开相应的CuRSOR。我将以下代码移到了PROCEDURE的底部:
SET DTDATE=(CURRENT DATE - 13 MONTHS);
SET STRSERVER=CURRENT SERVER;
SET STRUSER=USER;
SELECT GAGENCYID INTO STRAGENCYID FROM VINFWICIDUSER
WHERE GUSERID = STRUSER;
IF STRSERVER = 'HWDCH1TD' THEN
SET STRLOWAGENCYID ='100';
ELSE
SET STRLOWAGENCYID ='101';
END IF;
IF STRAGENCYID = PARMAGENCYID OR STRAGENCYID LIKE '*%' THEN
IF PARMAGENCYID = 'ALL' THEN
OPEN C_STATE; --The DECLARED CURSOR in first SELECT
ELSE
OPEN C_AGENCY; --The DECLARED CURSOR in the second SELECT
END IF;
END IF;
--=============================================================
--Handle Errors and Log them
--==============================================================
--EXEC Stored Proc WICQ00R (STORPROC_NAME, RETURN_CODE, MISC, strUser, CURRENT DATETIME)
END P1
我们有一个报告系统与CURSORS有问题所以不知道我将在哪里领导......
感谢您的回复。