开发者社区> 问答> 正文

sql存储过程创建报错,很懵逼啊 ?报错

为毛连创建存储过程都报错了,没怎么用过,不知道哪里出问题了
ERROR [42601] [IBM][DB2/NT] SQL0104N An unexpected token "CREATE OR REPLACE" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "".

图片说明

代码如下

CREATE OR REPLACE PROCEDURE queryfault (
  IN IN_CLASS VARCHAR(150),
  IN IN_FAULT CHARACTER(150)
)
result sets 1
LANGUAGE SQL
CALLED ON NULL INPUT
MODIFIES SQL DATA
BEGIN 
declare id integer;
     FOR V AS MYCURSOR CURSOR FOR 
            select id,name,type,SIMILARITY(in_class, name) f from (
            select id,name,'t1' type from Lib_knowtype where deleted=0 and isopen=3200
              union all 
            select id,name,'d1' type from Def_classify where deleted=0
              union all 
            select id,name,'d2' type from Def_classitem where deleted=0) t order by f desc
     DO
     set id=v.id;
     if v.f>=10 then
         FOR V2 AS MYCURSOR CURSOR FOR 
         WITH RPL (parentid, id, name) AS 
         ( 
         SELECT ROOT.parentid, ROOT.id, ROOT.name FROM Lib_knowtype ROOT where ROOT.ISOPEN=3200 and ROOT.id=id
         UNION ALL  
         SELECT CHILD.parentid, CHILD.id, CHILD.name FROM RPL PARENT, Lib_knowtype CHILD WHERE PARENT.id= CHILD.parentid 
         ) 
         select RPL.id, RPL.name from RPL
         do
         cur:begin
          DECLARE missionlist_list CURSOR WITH RETURN TO CALLER for
          select id,title from Lib_knowtopic where deleted=0 and status=201001 and typeid=V2.id;
          open cursor1;
          end cur;
          end for;
        end if;
     END FOR;
END;

展开
收起
爱吃鱼的程序员 2020-06-23 00:37:22 764 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    https://www.cnblogs.com/janehlp/p/7223460.html

    2020-06-23 00:37:41
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SQL Server在电子商务中的应用与实践 立即下载
GeoMesa on Spark SQL 立即下载
原生SQL on Hadoop引擎- Apache HAWQ 2.x最新技术解密malili 立即下载