CREATE PROCEDURE mypro @groupid char(8), @rightid char(8)
AS
    BEGIN    if not exists (select * from tsysb_right where userid=@groupid and rightid=@rightid)

insert into tsysb_right(userid,rightid,type) values(@groupId, @rightid, 1)    else

delete tsysb_right where userid=@groupid and rightid=@rightid    END

解决方案 »

  1.   

    CREATE PROCEDURE mypro (i_groupid char,i_rightid char)
    AS
    v_count number
        BEGIN
        select count(*) into v_count from tsysb_right where userid=i_groupid and rightid=i_rightid;
        if v_count=0 then
    insert into tsysb_right(userid,rightid,type) values(i_groupId, i_rightid, 1);
        else
    delete tsysb_right where userid=@groupid and rightid=i_rightid;
    end if;
        END;
      

  2.   

    CREATE PROCEDURE mypro (i_groupid char,i_rightid char)
    AS
    v_count number;
        BEGIN
        select count(*) into v_count from tsysb_right where userid=i_groupid and rightid=i_rightid;
        if v_count=0 then
    insert into tsysb_right(userid,rightid,type) values(i_groupId, i_rightid, 1);
        else
    delete tsysb_right where userid=@groupid and rightid=i_rightid;
    end if;
        END;
    少了一个分号  不好意思