首页 新闻 会员 周边 捐助

DB2存储过程 问题

0
悬赏园豆:5 [已关闭问题] 关闭于 2012-08-22 21:32

CREATE PROCEDURE skygetkey
(
IN "KEY" varchar(50),     
OUT "RETVAL" INTEGER
)
LANGUAGE SQL
NOT DETERMINISTIC
EXTERNAL ACTION
MODIFIES SQL DATA
CALLED ON NULL INPUT
INHERIT SPECIAL REGISTERS
BEGIN
IF Exists(SELECT name FROM skykeys WHERE name=KEY)
 THEN
  SELECT RETVAL=VALUE FROM skykeys WHERE name = KEY;
  SET RETVAL = isnull(RETVAL, 0) +1;
  UPDATE skykeys SET value = RETVAL WHERE name = KEY;
ELSE
  INSERT INTO skykeys VALUES(KEY, 1);
  SET RETVAL = 1;
END IF;
END

提示错误:

DB2 Database Error:
ERROR [42601] [IBM][DB2/LINUX] SQL0104N  An unexpected token "SELECT" was found following "E name=KEY)   THEN  ". 
Expected tokens may include:  "SET".  LINE NUMBER=15.  SQLSTATE=42601。

其中skykeys表只有两个字段name,value两个字段。

Alec-Yin的主页 Alec-Yin | 初学一级 | 园豆:188
提问于:2012-08-08 13:34
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册