日期:2014-05-17 浏览次数:20593 次
CREATE FUNCTION w_getPushMonet(@userId VARCHAR(40),@yeji MONEY) RETURNS MONEY
AS
BEGIN
DECLARE @job VARCHAR
DECLARE @unit VARCHAR
DECLARE @rate DOUBLE
DECLARE @minMoney DOUBLE
DECLARE @maxMoney DOUBLE
SELECT @job=JobTitle,@unit=BusinessUnitId FROM [User] WHERE UserId=@userId
DECLARE temp_ CURSOR FOR
SELECT c__yjed,c__yjedmax,c__tcxs FROM e__tcgz WHERE c__bm=@unit AND c__gw=@job;
OPEN temp_
FETCH NEXT FROM temp_ INTO @minMoney,@maxMoney,@rate
WHILE(@@FETCH_STATUS=0)
BEGIN
IF @maxMoney='' OR @maxMoney IS NULL
BEGIN
IF @yeji>=@minMoney
BEGIN
RETURN @rate
END
END
ELSE IF @minMoney<=@yeji AND @maxMoney>@yeji
BEGIN
RETURN @rate
END
END
FETCH NEXT FROM temp_ INTO @minMoney,@maxMoney,@rate
CLOSE temp_
DEALLOCATE temp_
END
CREATE FUNCTION w_getPushMonet(@userId VARCHAR(40),@yeji MONEY)
RETURNS MONEY
AS
BEGIN
DECLARE @job VARCHAR(10)
DECLARE @unit VARCHAR(10)
DECLARE @rate BIGINT
DECLARE @minMoney BIGINT
DECLARE @maxMoney BIGINT
SELECT @job=JobTitle,@unit=BusinessUnitId FROM [User] WHERE UserId=@userId
DECLARE temp_ CURSOR FOR
SELECT c__yjed,c__yjedmax,c__tcxs FROM e__tcgz WHERE c__bm=@unit AND c__gw=@job;
OPEN temp_
FETCH NEXT FROM temp_ INTO @minMoney,@maxMoney,@rate
WHILE(@@FETCH_STATUS=0)