p_issue_apply

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: wKF36280,吴正兵
-- Create date: 2011/05/24
-- Description: 问题承诺未审批处理所有问题ID(定义临时表字段太多)
-- =============================================
ALTER PROCEDURE [dbo].[p_private_issue_todo](
@CurrentID               INT,
@SolutionEditionId       INT
)
AS
DECLARE @strID                 Nvarchar(1000)   --已处理问题ID
DECLARE @issueSequence         Nvarchar(15)     --问题序号sequence
DECLARE @id                    INT              --问题主键
DECLARE @count                 INT              --问题统计
DECLARE @issueCount            INT              --问题个数
SELECT @issueCount = 0
CREATE TABLE #T_IAID(
id INT,
    sequence Nvarchar(15)
)ON [PRIMARY]
DECLARE IssueApplyCursor SCROLL CURSOR FOR
SELECT t.str_issue_sequence FROM t_issue_apply t WHERE t.i_issue_app_id > @CurrentID AND t.i_solution_edition_id = @SolutionEditionId ORDER BY i_issue_app_id
OPEN IssueApplyCursor
WHILE 1 = 1
BEGIN
FETCH NEXT FROM IssueApplyCursor INTO @issueSequence
IF @@FETCH_STATUS != 0 OR @issueCount = 10
BEGIN
break
End
BEGIN
SELECT @count = count(*) FROM t_issue_apply t
WHERE t.str_issue_sequence like '%' + substring(@issueSequence,2,15)
IF @count=1         
BEGIN           
SELECT @id = t.i_issue_app_id FROM t_issue_apply t WHERE t.str_issue_sequence = @issueSequence
SELECT @issueCount = @issueCount + 1
            INSERT INTO #T_IAID(id,sequence) VALUES(@id,@issueSequence)
END
END
END
CLOSE IssueApplyCursor
DEALLOCATE IssueApplyCursor

SELECT * FROM #T_IAID
DROP TABLE #T_IAID

你可能感兴趣的:(Go)