What is wrong with this stored procedure

房东的猫 提交于 2019-12-13 04:27:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!