다음의 mssql에서의 유저정의펑션을
오라클에서 표현하려 합니다
CREATE FUNCTION GetVersionFrom
( --@NUM INT
)
RETURNS varchar(2000)
AS
BEGIN
DECLARE VERSION_CURSOR CURSOR
FOR
SELECT VERSION_ID
FROM STD_REQ_VERSION
ORDER BY VERSION_ORDER
OPEN VERSION_CURSOR
DECLARE @VERSION_ID int
DECLARE @ITER int
DECLARE @ITER_STR varchar(200)
DECLARE @VERSION_STR varchar(2000)
--DECLARE @STRNUM varchar(200)
SET @VERSION_STR = ''
--SET @STRNUM =CONVERT(VARCHAR, @NUM)
SET @ITER = 0
/* Iteration For Each Records */
FETCH NEXT FROM VERSION_CURSOR INTO @VERSION_ID
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
BEGIN
/*Make Query For Each Class */
SET @ITER=@ITER + 1
SET @ITER_STR = CONVERT(VARCHAR, @ITER)
SET @VERSION_STR = @VERSION_STR +
' LEFT OUTER JOIN REQ_VALUE_VERSION A' + @ITER_STR + ' ON ' +
'A' + @ITER_STR + '.REQ_ID = C.OBJ_ID and ' +
'A' + @ITER_STR + '.REQ_MODEL_ID = C.OBJ_ID_PARENT and ' +
'A' + @ITER_STR + '.VERSION = ' +CONVERT(VARCHAR, @VERSION_ID)
END
FETCH NEXT FROM VERSION_CURSOR INTO @VERSION_ID
END
CLOSE VERSION_CURSOR
DEALLOCATE VERSION_CURSOR
RETURN @VERSION_STR
END
어떻게 바꾸면 될까요?
|