<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template name="Put.InventoryUpdate">
<AspDotNetStorefrontImport Version="7.1">
<ExecuteSQL Name="UpdateInventory">
<xsl:for-each select="Item_Items/Item_Item">
<SQL>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
update product set quantity = 4 where sku = N'<xsl:value-of select="SKU"></xsl:value-of>';
-- We should only ever find one inventory value to update
IF @resultCount <xsl:text disable-output-escaping="yes">></xsl:text> 1
begin
RAISERROR ('THERE WAS AN ERROR, SHOULD ONLY BE ONE INVENTORY VALUE, NOT UPDATING INVENTORY', 16, 1);
end
else if @resultCount = 0
begin
declare @err nvarchar(500) = 'THERE WAS AN ERROR, NO INVENTORY VALUE WAS FOUND';
RAISERROR (@err, 16, 1);
end
else
begin
update inventory set Quan = @quantity where InventoryID = (select id from @results);
end
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</SQL>
</xsl:for-each>
</ExecuteSQL>
</AspDotNetStorefrontImport>
</xsl:template>
</xsl:stylesheet>