0

以下のコードを使用して関数を作成しますが、実行したいときにエラーが発生します

CREATE FUNCTION getFactorPriceFunction
(
    @factorCode BIGINT
)
RETURNS bigint
AS BEGIN
    RETURN 
    (
        select SUM(price*coun) as total from CustomerFactor inner join CustomerFactorDetails 
        on CustomerFactor.code=CustomerFactorDetails.factorCode inner join ProductDetails on
        ProductDetails.code=CustomerFactorDetails.productDetailsCode
        where factorCode=@factorCode AND final=1
    )
END 

実行する:

 select total from getFactorPriceFunction(100)

エラー:

無効なオブジェクト名「getFactorPriceFunction」

4

2 に答える 2

0
  1. と呼ばれていdbo.getFactorPriceFunctionます。
  2. 呼び出しは次のようになります。

    select dbo.getFactorPriceFunction(100) as total
    
于 2013-05-23T04:33:38.420 に答える
-1

これはscalar value関数なので、次のように実行する必要があります

select dbo.getFactorPriceFunction(100)

テーブルを返す場合は、

select total from dbo.getFactorPriceFunction(100)
于 2013-05-23T04:34:04.837 に答える