Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Stored Procedure to insert xml with sequences into database as single row

$
0
0

Hi, have an XML file that has sequences for multiple address lines and while using OPENXML I can't seem to load the values in these subs as a single row (or load at all).

Here's the XML with the addy sequences bolded:

<?xml version="1.0" encoding="UTF-8"?>
<SyncSalesOrder xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.infor.com/2.6.4/InforOAGIS/BODs/Developer/SyncSalesOrder.xsd" versionID="2.6.4" systemEnvironmentCode="Production" releaseID="9.2" languageCode="en-US">
<!--TX_REF:ReferenceID=1.1.1084727-->
<!--TX_REF:AccountingEntityID=S10a7089..C.01-->
<ApplicationArea>
<Sender>
<LogicalID>lid://infor.xa.s10a7089-99</LogicalID>
<ComponentID>ERP</ComponentID>
</Sender>
<CreationDateTime>2013-11-22T00:05:22Z</CreationDateTime>
<BODID>infor-nid:infor:S10a7089..C.01::1.1.1084727:?SalesOrder&amp;verb=Sync</BODID>
</ApplicationArea>
<DataArea>
<Sync>
<TenantID>infor</TenantID>
<AccountingEntityID>S10a7089..C.01</AccountingEntityID>
<ActionCriteria>
<ActionExpression actionCode="Replace"/>
</ActionCriteria>
</Sync>
<SalesOrder>
<SalesOrderHeader>
<DocumentID>
<ID accountingEntity="S10a7089..C.01" variationID="20131122000522" lid="lid://infor.xa.s10a7089-99">1.1.1084727</ID>
</DocumentID>
<DisplayID>1.1.1084727</DisplayID>
<AlternateDocumentID>
<ID>J.L./BC</ID>
</AlternateDocumentID>
<DocumentDateTime>2012-12-07T15:20:04Z</DocumentDateTime>
<Status>
<Code>Hold</Code>
</Status>
<CustomerParty>
<PartyIDs>
<ID accountingEntity="" lid="lid://infor.xa.s10a7089-99"/>
</PartyIDs>
<Name>SPORTSMAN'S WAREHOUSE</Name>
<Location>
<Address>
<FormatCode>1</FormatCode>
<AttentionOfName>HAILEY ANDERSON</AttentionOfName>
<AddressLine sequence="1">7035 S. HIGH TECH DR. SUITE 200</AddressLine>
<AddressLine sequence="2"/>
<AddressLine sequence="3"/>
<AddressLine sequence="4"/>
<AddressLine sequence="5"/>
<CityName>MIDVALE</CityName>
<CountrySubDivisionCode listID="US States">UT</CountrySubDivisionCode>
<CountryCode>US</CountryCode>
<PostalCode>84047-3759</PostalCode>
</Address>
</Location>
</CustomerParty>
<ShipToParty>
<Name>SPORTSMAN'S WAREHOUSE #119 RETAIL</Name>
<Location>
<Address>
<AddressLine sequence="1">11 WEST 84TH AVE.</AddressLine>
<AddressLine sequence="2">ATTN* ARCHERY DEPT.</AddressLine>
<AddressLine sequence="3"/>
<AddressLine sequence="4"/>
<AddressLine sequence="5"/>
<CityName>THORNTON</CityName>
<CountrySubDivisionCode listID="US States">CO</CountrySubDivisionCode>
<CountryCode>US</CountryCode>
<PostalCode>80260</PostalCode>
</Address>
</Location>
</ShipToParty>
<ContractReference>
<DocumentID>
<ID accountingEntity=""/>
</DocumentID>
</ContractReference>
<ExtendedAmount currencyID="">0.00</ExtendedAmount>
<TotalAmount currencyID="">0.00</TotalAmount>
<BillToParty>
<PartyIDs>
<ID accountingEntity="" lid="lid://infor.xa.s10a7089-99"/>
</PartyIDs>
<Name>SPORTSMAN'S WAREHOUSE</Name>
<Location>
<Address>
<AttentionOfName>SPORTSMAN'S WAREHOUSE</AttentionOfName>
<AddressLine sequence="1">7035 S. HIGH TECH DR. SUITE 200</AddressLine>
<CityName>MIDVALE</CityName>
<CountrySubDivisionCode listID="US States">UT</CountrySubDivisionCode>
<CountryCode>US</CountryCode>
<PostalCode/>
</Address>
</Location>
</BillToParty>
<CarrierParty>
<PartyIDs>
<ID>P01</ID>
</PartyIDs>
<Name>USPS- First Class Regular</Name>
</CarrierParty>
<PayFromParty>
<PartyIDs>
<ID accountingEntity="" lid="lid://infor.xa.s10a7089-99"/>
</PartyIDs>
</PayFromParty>
<PaymentTerm>
<IDs>
<ID>2</ID>
</IDs>
</PaymentTerm>
<DistributedCharge>
<Amount currencyID="">0</Amount>
</DistributedCharge>
<DistributedTax>
<TaxAuthorityAmount currencyID="">0</TaxAuthorityAmount>
</DistributedTax>
<RequestedShipDateTime>2012-12-07T00:00:00Z</RequestedShipDateTime>
<SalesPersonReference>
<IDs>
<ID accountingEntity=""/>
</IDs>
<Name>GL WARRANTY-WARRANTY DEPT</Name>
</SalesPersonReference>
<ExtendedPretaxAmount currencyID="">0.00</ExtendedPretaxAmount>
<BaseCurrencyAmount type="ExtendedPretaxAmount">
<Amount currencyID="">0.00</Amount>
</BaseCurrencyAmount>
<BaseCurrencyAmount type="TotalAmount">
<Amount currencyID="">0.00</Amount>
</BaseCurrencyAmount>
</SalesOrderHeader>
</SalesOrder>
</DataArea>
</SyncSalesOrder>

Here's the core SP, I should add that all the other data loads, just not from the sequences.


FROM OPENXML (@xmlDoc, '/DataArea/SalesOrder', 1)
WITH (
SONumber varchar(50) 'SalesOrderHeader/DocumentID/ID',
SOType varchar(50) 'SalesOrderHeader/DocumentID/ID',
SOCompany varchar(50) 'SalesOrderHeader/DocumentID/ID',
        SORef varchar(50) 'SalesOrderHeader/AlternateDocumentID',
        SOStatus varchar(50) 'SalesOrderHeader/Status/Code',
SOCustName varchar(50) 'SalesOrderHeader/CustomerParty/Name',
SOCustNumber varchar(50) 'SalesOrderHeader/CustomerParty/Name',
SOAddr1 varchar(50) 'CustomerParty/Location/Address/AddressLine[@sequence="1"]',
               SOAddr2 varchar(50) 'CustomerParty/Location/Address/AddressLine[@sequence="2"]',
               SOAddr3 varchar(50) 'CustomerParty/Location/Address/AddressLine[@sequence="3"]',
               SOCity varchar(50) 'SalesOrderHeader/CustomerParty/Location/Address/CityName',
       SOState varchar(50) 'SalesOrderHeader/CustomerParty/Location/Address/CountrySubDivisionCode',
               SOPostal varchar(50) 'SalesOrderHeader/CustomerParty/Location/Address/PostalCode'
)

EXEC sp_xml_removedocument @xmlDoc

Thanks very much


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>