标题:请高手帮忙看看这个存储过程是什么意思?
只看楼主
zbxiaofei
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-1-16
 问题点数:0 回复次数:0 
请高手帮忙看看这个存储过程是什么意思?
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO





-- SELECT * FROM F_WORKER
-- EXEC R_SAVERIGHT 3, 1


ALTER        PROCEDURE R_SAVERIGHT(@ISWORKER BIT, @CODE INT)
AS
BEGIN

  INSERT INTO R_MODULE_RIGHT(DCODE, DMODULENO, DOPERATION, DKIND)
  SELECT @CODE, DMODULEKINDNO, 0, @ISWORKER
  FROM S_RIGHT_ALLOCATE WHERE DMODULEKINDNO NOT IN
      (SELECT DMODULENO FROM R_MODULE_RIGHT WHERE DKIND = @ISWORKER AND DCODE = @CODE)
  
--如果有任意一个审核,则将单据审核加权限。
--如果有任意一个记账,则将单据记账加权限。
  IF EXISTS(SELECT TOP 1 1 FROM S_RIGHT_ALLOCATE WHERE DCANAUDIT = 1)
  BEGIN
    UPDATE S_RIGHT_ALLOCATE SET DACCESS = 1 WHERE DMODULEKINDNO = '030001'
  END

  IF EXISTS(SELECT TOP 1 1 FROM S_RIGHT_ALLOCATE WHERE DCANDZ = 1)
  BEGIN
    UPDATE S_RIGHT_ALLOCATE SET DACCESS = 1 WHERE DMODULEKINDNO = '030002'
  END

  UPDATE R_MODULE_RIGHT SET
  DOPERATION = B.DRIGHT
  FROM R_MODULE_RIGHT,
   (SELECT DMODULEKINDNO,
          DCANSETGRID * POWER(2, 13) +
          DCANSPLIT * POWER(2, 12) +
          DCANCOMBINE * POWER(2, 11) +
          DCANBATCHUPDATE * POWER(2, 10) +
          DCANIMPORT * POWER(2, 9) +
          DCANDUPLICATE * POWER(2, 8) +
          DCANBACK * POWER(2, 7) +
          DCANZF * POWER(2, 6) +
          DCANDZ * POWER(2, 5) +
          DCANAUDIT * POWER(2, 4) +
          DCANINPUT * POWER(2, 3) +
          DCANPRINTDESIGN * POWER(2, 2) +
          DCANPRINT * POWER(2, 1) +
          DACCESS * POWER(2, 0)
        AS DRIGHT
    FROM S_RIGHT_ALLOCATE) B
  WHERE R_MODULE_RIGHT.DMODULENO = B.DMODULEKINDNO
       AND R_MODULE_RIGHT.DKIND = @ISWORKER AND R_MODULE_RIGHT.DCODE = @CODE



  DECLARE @PLACE U_SHOPNO

  IF @ISWORKER = 1
  BEGIN
  --取得员工所在的机构,进行发送
    SELECT @PLACE = DSHOPNO FROM F_WORKER WHERE DWORKERCODE = @CODE
  
    DECLARE @ERROR INT, @ERRORID INT
    IF @PLACE <> DBO.SF_GETCURRENTSHOP()
    EXEC @ERROR = SP_TRANSBASE '0250', @PLACE

    SET @ERRORID = 40004
    IF @ERROR <> 0 GOTO ERROR1
  END

RETURN
  ERROR1:
  EXEC SP_DEALERROR 'R_SAVERIGHT', @ERRORID, 0
  RAISERROR(@ERROR, 16, 1)
  RETURN ISNULL(@ERRORID, -1)

END









GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
2008-01-16 16:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-197670-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.130618 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved