简体   繁体   中英

Not able to create stored procedure in DB2

I am trying to create a stored procedure in DB2 using IBM DB2 Cloud. I am getting the error as:

An Unexpected token 'END-OF-STATEMENT' was found following "".

Detail about the error is seen in the screenshot below.

Click here for error screenshot

CREATE PROCEDURE trial_pro(in msg varchar(100))
language sql;
BEGIN
    insert into collision values(msg);;
END

First of all:

  • There ";" behind language sql is wrong.
  • Two ";" after the line with the insert do not make sense and do not match with the screenshot.

In addition to that: While ";" is the statement terminator inside your stored procedure make sure to choose (configure) another one for the (outer) create procedure statement. Usually the tools you run the SQLs offer a option to change it.

You must change the default statement terminator ( ; ) if you use a compound statement.
In the DSM console you can do it either temporarily for some particular statement:

--#SET TERMINATOR @
CREATE PROCEDURE trial_pro(in msg varchar(100))
language sql
BEGIN
    insert into collision values(msg);
END@
--#SET TERMINATOR ;

or set it by default with:

Editor options (gear icon at the top right corner) -> Statement terminator -> @

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM