用友ERP U9枚舉SQL查詢

首先創函數:

CREATE FUNCTION f_WK_GetEnum 

(

-- Add the parameters for the function here
@enumtype nvarchar(200),
@evalue int
)
RETURNS nvarchar(200)
AS
BEGIN
-- Declare the return variable here
DECLARE @rtnvalue nvarchar(200)
-- Add the T-SQL statements to compute the return value here
select @rtnvalue=max(subb.Name) from UBF_Sys_ExtEnumValue suba join UBF_Sys_ExtEnumValue_Trl subb on suba.id=subb.ID join UBF_Sys_ExtEnumType subc on suba.ExtEnumType=subc.ID where subc.Code=@enumtype and suba.EValue=@evalue
-- Return the result of the function
RETURN @rtnvalue
END


查詢中調用函數:
select DemandCode,--UFIDA.U9.CBO.Enums.DemandCodeEnum,
dbo.f_WK_GetEnum('UFIDA.U9.CBO.Enums.DemandCodeEnum',DemandCode),
* from MO_MO where DOCNO='MO-2016121010832' 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章