C
CShrek
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个自定义函数,代码如下CREATE FUNCTION dbo.RTO_C(@IDX VARCHAR(10),@QTY NUMERIC(28,8)) RETURNS NUMERIC(28,8)ASBEGIN DECLARE @RTO_QTY NUMERIC(28,8) DECLARE @QTY1 INT DECLARE @QTY2 INT DECLARE @RTO_ID VARCHAR(1) DECLARE @QTY_UP_RTO INT DECLARE @QTY_C NUMERIC(28,8) DECLARE @QTY_RTO INT DECLARE @RTO NUMERIC(28,8) SET @QTY1=(SELECT QTY_SO1 FROM RTO_GS WHERE IDX1=@IDX AND @QTY>=QTY_SO1 AND @QTY<=QTY_SO2) SET @QTY2=(SELECT QTY_SO2 FROM RTO_GS WHERE IDX1=@IDX AND @QTY>=QTY_SO1 AND @QTY<=QTY_SO2) SET @RTO_ID=(SELECT RTO_ID FROM RTO_GS WHERE IDX1=@IDX AND @QTY>=QTY_SO1 AND @QTY<=QTY_SO2) SET @QTY_UP_RTO=(SELECT QTY_UP_RTO FROM RTO_GS WHERE IDX1=@IDX AND @QTY>=QTY_SO1 AND @QTY<=QTY_SO2) SET @QTY_RTO=(SELECT ISNULL(QTY_RTO,0) FROM RTO_GS WHERE IDX1=@IDX AND @QTY>=QTY_SO1 AND @QTY<=QTY_SO2) SET @RTO=(SELECT ISNULL(RTO,0) FROM RTO_GS WHERE IDX1=@IDX AND @QTY>=QTY_SO1 AND @QTY<=QTY_SO2) IF @QTY>=@QTY1 AND @QTY<=@QTY2 BEGIN IF @RTO_ID='Y' BEGIN SET @RTO_QTY=@QTY_RTO END IF @RTO_ID<>'Y' BEGIN SET @QTY_C=ISNULL(@QTY,0)-ISNULL(@QTY1,0) SET @RTO_QTY=@QTY_UP_RTO+@QTY_C*@RTO END END RETURN @RTO_QTYEND我在SQL中执行 select RTO_C('11',4000) 提示说我这个函数不识别'RTO_C' is not a recognized function name.