Error while creating procedure in db2

放肆的年华 提交于 2019-12-25 01:46:52

问题


I got error while creating procedure in db2.

Error is - Expected tokens may include: psm_semicolon.. SQLCODE=-104

Help Me....

CREATE PROCEDURE update_new()
LANGUAGE SQL
BEGIN
CREATE TABLE TEMP(METADATA_KEY varchar(40),NEW_METADATA_KEY varchar(40));
END;

回答1:


In whatever tool you're using, change the statement terminator to something other than semicolon and put that terminator at the end of the CREATE PROCEDURE statement.

For example, if using the command line processor, save this to a file (note the "@" symbol at the end:

CREATE PROCEDURE update_new()
LANGUAGE SQL
BEGIN
 CREATE TABLE TEMP(METADATA_KEY varchar(40),NEW_METADATA_KEY varchar(40));
END@

then execute the file: db2 -td@ -f myproc.sql

The reason for doing this is that semicolons are always used as terminators within the procedure code, so you must use something else to terminate the CREATE PROCEDURE statement.



来源:https://stackoverflow.com/questions/28766241/error-while-creating-procedure-in-db2

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