iSeries ナビゲーターを使用して、db2 データベースで次のストアド プロシージャを実行しようとしています。
CREATE PROCEDURE ZSPPQDELETEUSERIDBA (
IN P_USERID CHAR(10) ,
IN P_BUSINESSAREA CHAR(10))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC ZSPPQDELETEUSERIDBA
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
SELECT Count (*) FROM USERBUSINESSAREA
WHERE USERID = P_USERID
AND BUSINESSAREA = P_BUSINESSAREA;
OPEN C1;
FETCH C1 INTO TOTALCNT;
IF ( TOTALCNT = 1) THEN
DELETE
FROM USERBUSINESSAREA
WHERE USERID = P_USERID
AND BUSINESSAREA = P_BUSINESSAREA;
END IF;
END P1 ;
上記の手順を実行しようとすると、次のエラーが発生します。
SQL State: 42601
Vendor Code: -199
Message: [SQL0199] Keyword SELECT not expected. Valid tokens: FOR WITH WITHOUT. Cause . . . . . : The keyword SELECT was not expected here. A syntax error was detected at keyword SELECT. The partial list of valid tokens is FOR WITH WITHOUT. This list assumes that the statement is correct up to the unexpected keyword. The error may be earlier in the statement but the syntax of the statement seems to be valid up to this point. Recovery . . . : Examine the SQL statement in the area of the specified keyword. A colon or SQL delimiter may be missing. SQL requires reserved words to be delimited when they are used as a name. Correct the SQL statement and try the request again.
ここで何がうまくいかないのですか?