日期:2014-05-16 浏览次数:20891 次
USE [EachflyPM]
GO
/****** Object: StoredProcedure [dbo].[Sp_SubmitTaskPlanMonth] Script Date: 04/09/2014 09:03:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Batch submitted through debugger: SQLQuery15.sql|7|0|C:\Users\Administrator\AppData\Local\Temp\~vs37CD.sql
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[Sp_SubmitTaskPlanMonth]
@PP_ID varchar(2000),
@WbsIDList varchar(8000), --任务ID列表
@Submiter varchar(50) -- 提交人ID
AS
BEGIN
DECLARE @object_id nvarchar(500)
DECLARE @i INT
DECLARE @len INT
DECLARE @count INT
declare @keyid varchar(50)
declare @sql varchar(2000)
declare @k int
declare @PP_year int
declare @PP_Month int
--print @WbsIDList
IF (@WbsIDList IS NULL)
RETURN
IF (LTRIM(@WbsIDList) = '')
RETURN
SET @WbsIDList = @WbsIDList + ',' -- 特殊处理,便于后续循环
select @PP_year = PP_Year from FlyPM_PrjPlan where PP_ID = @PP_ID
select @PP_Month = PP_Month from FlyPM_PrjPlan where PP_ID = @PP_ID
WHILE CHARINDEX(',',@WbsIDList) > 0
BEGIN
SET @len = LEN(@WbsIDList)
SET @i = CHARINDEX(',', @WbsIDList)
SET @object_id = LEFT(@WbsIDList, @i-1)
set @k = 1
--为啥下面的@PP_year和@PP_Month获取不到
IF not exists(select PP_ID from FlyPM_PrjPlan where PP_Year = @PP_year and PP_Month = @PP_Month and PP_Status = 1 and PP_Version = 2)
BEGIN
EXEC EachflyPlatform.dbo.sp_System_FlowID_Create 'PM','FlyPM_PrjPlan',@keyId output
INSERT INTO FlyPM_PrjPlan(PP_ID,PP_Year,PP_Month,PP_Status,PP_Version) values(@keyid,@PP_year,@PP_Month,1,2)
END
ELSE
BEGIN
set @keyid = @PP_ID
END
--其他代码
SET @WbsIDList = RIGHT(@WbsIDList, @len - @i)
END
END