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

From dbscript Online Help
Jump to: navigation, search
Line 3: Line 3:
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|-
 
|-
| '''function
+
| '''Function
 
| dbo.ufnGetStock
 
| dbo.ufnGetStock
 
|- valign="top"
 
|- valign="top"
Line 11: Line 11:
 
|}
 
|}
  
 +
 +
=== Source ===
 
<pre>
 
<pre>
 
CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int])
 
CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int])
Line 31: Line 33:
 
</pre>
 
</pre>
  
 
+
=== References ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
Line 44: Line 46:
  
 
|}
 
|}
 
  
  

Revision as of 00:07, 3 February 2010

wikibot

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


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;

References

Dependency Type Object Type Referenced Object
Select Table Production.ProductInventory


automatically generated

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