2 u010713523 u010713523 于 2013.09.27 14:03 提问

navcat中创建存储过程遇到的不识别的问题

本人是个菜鸟,在navicat中创建存储过程时遇到的问题

CREATE procedure CountLayer  (in node int,out result int)
begin  
    declare result,lft1, rgt1 int;
    if exists(select Node_id from Tree where Node_id = node); 
    begin 
        select lft1 = Lft,rgt1 = Rgt from Tree where( Node_id = node);
        select result = count(*) from Tree where Lft <= lft1 and Rgt >= rgt1;  
    end  
    return result  
end 
GO

然后错误

[SQL] CREATE procedure CountLayer  (in node int,out result int)
begin  
    declare result,lft1, rgt1 int;
    if exists(select Node_id from Tree where Node_id = node); 
    begin 
        select lft1 = Lft,rgt1 = Rgt from Tree where( Node_id = node);
        select result = count(*) from Tree where Lft <= lft1 and Rgt >= rgt1;  
    end  
    return result  
end 
GO

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; 
    begin 
        select lft1 = Lft,rgt1 = Rgt from Tree where( Node_id = ' at line 4

跪求跪求大神解决。。。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!