问题
What is wrong with this stored procedure.
CREATE PROCEDURE PROC_RESULT_SET ()
LANGUAGE SQL
RESULT SETS 1
BEGIN
DECLARE MYCUR CURSOR WITH RETURN FOR
SELECT USERNAME , NAME FROM SLPG.USER ORDER BY ID;
OPEN MYCUR;
END;
I get error like
DB2 for Linux, UNIX, and Windows: "END" was expected to form a complete scope. -- near BEGIN statement
DB2 for Linux, UNIX, and Windows: "" was expected to form a complete scope. -- near DECLARE statement
DB2 for Linux, UNIX, and Windows: " JOIN " was expected to form a complete scope. -- near OPEN statement
DB2 for Linux, UNIX, and Windows: Unexpected text "END" encountered. -- near END statement
回答1:
You need to use a different terminator for the CREATE PROCEDURE statement itself, as the semicolon is used to terminate statements within the procedure body.
来源:https://stackoverflow.com/questions/20876637/what-is-wrong-with-this-stored-procedure