ScrewTurn Wiki

Edit

wikibot

Functiondbo.ufnGetStock
DescriptionScalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID.

Edit

Source

CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int])
RETURNS [int] 
AS 
-- Returns the stock level for the product. This function is used internally only
BEGIN
    DECLARE @ret int;
    
    SELECT @ret = SUM(p.[Quantity]) 
    FROM [Production].[ProductInventory] p 
    WHERE p.[ProductID] = @ProductID 
        AND p.[LocationID] = '6'; -- Only look at inventory in the misc storage
    
    IF (@ret IS NULL) 
        SET @ret = 0
    
    RETURN @ret
END;

Edit

References

Dependency TypeObject TypeReferenced Object
SelectTableProduction.ProductInventory

Edit

automatically generated

function dbo.ufnGetStock
DescriptionScalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID.


CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int])
RETURNS [int] 
AS 
-- Returns the stock level for the product. This function is used internally only
BEGIN
    DECLARE @ret int;
    
    SELECT @ret = SUM(p.[Quantity]) 
    FROM [Production].[ProductInventory] p 
    WHERE p.[ProductID] = @ProductID 
        AND p.[LocationID] = '6'; -- Only look at inventory in the misc storage
    
    IF (@ret IS NULL) 
        SET @ret = 0
    
    RETURN @ret
END;

Dependency TypeObject TypeReferenced Object
SelectTableProduction.ProductInventory

ScrewTurn Wiki version 2.0.36. Some of the icons created by FamFamFam.