Difference between revisions of "Dbo.ufnGetStock (function)"
(New page: == wikibot == {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" |- | '''function | dbo.ufnGetStock |- |} <pre> CREATE FUNCTION [dbo].[ufnGetStock](@ProductID...) |
|||
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== wikibot == | == wikibot == | ||
| + | |||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- valign="top" | ||
| + | | '''Function | ||
| + | | dbo.ufnGetStock | ||
| + | |- valign="top" | ||
| + | | '''Description | ||
| + | | Scalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID. | ||
| + | |} | ||
| + | |||
| + | === Source === | ||
| + | <pre> | ||
| + | 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; | ||
| + | </pre> | ||
| + | |||
| + | === References === | ||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- style="background:silver" | ||
| + | | '''Dependency Type | ||
| + | | '''Object Type | ||
| + | | '''Referenced Object | ||
| + | |||
| + | |- valign="top" | ||
| + | | Select | ||
| + | | Table | ||
| + | | [[Production.ProductInventory_(table)|Production.ProductInventory]] | ||
| + | |||
| + | |} | ||
| + | |||
| + | |||
| + | == automatically generated == | ||
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| Line 5: | Line 52: | ||
| '''function | | '''function | ||
| dbo.ufnGetStock | | dbo.ufnGetStock | ||
| + | |- valign="top" | ||
| + | | '''Description | ||
| + | | Scalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID. | ||
|- | |- | ||
|} | |} | ||
<pre> | <pre> | ||
| + | |||
CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int]) | CREATE FUNCTION [dbo].[ufnGetStock](@ProductID [int]) | ||
RETURNS [int] | RETURNS [int] | ||
| Line 27: | Line 78: | ||
END; | END; | ||
</pre> | </pre> | ||
| + | |||
| + | |||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- style="background:silver" | ||
| + | | '''Dependency Type | ||
| + | | '''Object Type | ||
| + | | '''Referenced Object | ||
| + | |||
| + | |- | ||
| + | | Select | ||
| + | | Table | ||
| + | | [[Production.ProductInventory_(table)|Production.ProductInventory]] | ||
| + | |||
| + | |} | ||
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 |