Difference between revisions of "Dbo.ufnGetStock (function)"

From dbscript Online Help
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
  
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
|-
+
|- valign="top"
 
| '''Function
 
| '''Function
 
| dbo.ufnGetStock
 
| dbo.ufnGetStock
Line 8: Line 8:
 
| '''Description
 
| '''Description
 
| Scalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID.
 
| Scalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID.
|-
 
 
|}
 
|}
 
  
 
=== Source ===
 
=== Source ===
Line 40: Line 38:
 
| '''Referenced Object
 
| '''Referenced Object
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table

Latest revision as of 23:15, 23 June 2010

wikibot[edit]

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

Source[edit]

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;

References[edit]

Dependency Type Object Type Referenced Object
Select Table Production.ProductInventory


automatically generated[edit]

function dbo.ufnGetStock
Description Scalar 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 Type Object Type Referenced Object
Select Table Production.ProductInventory