아래소스중 찐한부분 #TEMP 이건 뭘뜻하는건지요??
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[KM_US_SET_GROUP_HIERARCHY]
(
@GROUPID VARCHAR(50)
)
AS
DECLARE @GROUP_LEVEL NUMERIC, @CURRENT NUMERIC, @COUNT NUMERIC, @TEMPGROUPID VARCHAR(50),
@TEMP_SEQ NUMERIC(1) ,@CURRENT_ID VARCHAR(50), @CURRENT_NM VARCHAR(500)
BEGIN
DELETE FROM IKEP_US_GROUP_HIERARCHY WHERE GROUPID=@GROUPID
INSERT INTO IKEP_US_GROUP_HIERARCHY(GROUPID, NAME)
SELECT ID, NAME FROM IKEP_US_GROUP WHERE ID=@GROUPID
SET @CURRENT = 0
SET @TEMPGROUPID = @GROUPID
WHILE @CURRENT >= 0
BEGIN
IF EXISTS (SELECT ID FROM IKEP_US_GROUP WHERE ID=@TEMPGROUPID )
BEGIN
INSERT INTO #TEMP(SEQ, GROUPID, NAME)
SELECT @CURRENT, ID, NAME FROM IKEP_US_GROUP WHERE ID = @TEMPGROUPID
SELECT @TEMPGROUPID =PARENTGROUPID FROM IKEP_US_GROUP WHERE ID = @TEMPGROUPID
IF EXISTS (SELECT PARENTGROUPID FROM IKEP_US_GROUP WHERE ID = @TEMPGROUPID )
SET @CURRENT = @CURRENT +1
ELSE
BEGIN
SET @GROUP_LEVEL = @CURRENT
SET @CURRENT = -1
END
END
ELSE
RETURN
END
DECLARE HEIARCHYCursor CURSOR FOR
SELECT SEQ FROM #TEMP ORDER BY SEQ DESC
OPEN HEIARCHYCursor
FETCH NEXT FROM HEIARCHYCursor INTO @TEMP_SEQ