Skip to content

Instantly share code, notes, and snippets.

@lanekatris
Created November 7, 2015 05:01
Show Gist options
  • Select an option

  • Save lanekatris/06ec77d999b9918c4cdc to your computer and use it in GitHub Desktop.

Select an option

Save lanekatris/06ec77d999b9918c4cdc to your computer and use it in GitHub Desktop.
<?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">&lt;![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">&gt;</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">]]&gt;</xsl:text>
</SQL>
</xsl:for-each>
</ExecuteSQL>
</AspDotNetStorefrontImport>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment