Getting Started with Adobe After Effects - Part 6: Motion Blur
Ask
Ask questions, discuss or help others by answering
Related Posts · View All
SQL Server 141
TSQL 75
SSRS 70
SSIS 66
XML 54

Top Categories · View All
SQL Server 141
TSQL 75
SSRS 70
SSIS 66
XML 54

Working around the <xs:choice> element...

Apr 30 2010 12:00AM by hunterjl   

I do not quite understand why my Bulk Load fails when I run it.  Here is all my information...

I handle the XMLBulkLoad object using VB.NET and here is the code...

Dim objBL As Object = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad.4.0")

objBL.ConnectionString = "provider=SQLOLEDB;data source=server;database=db;integrated security=SSPI"

objBL.ErrorLogFile = "c:\error.log"

objBL.CheckConstraints = True

objBL.KeepIdentity = False

objBL.SGDropTables = True

objBL.SchemaGen = True

objBL.Execute(C:\schema.xsd", "C:\data.xml")

objBL = Nothing

Here is a sample of my XSD...This sample begins immediately below my annotations/appinfo section, which describes the relationships being created.

<xs:element name="Package" sql:is-constant="1">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" name="PackageHeader" sql:relation="FE_PackageHeader">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="PackageName" type="xs:string" />
              <xs:element minOccurs="0" name="Universe" type="xs:string" />
              <xs:element minOccurs="0" name="AsOfDate" type="xs:date" sql:datatype="dateTime" />
              <xs:element minOccurs="0" name="Version" type="xs:decimal" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" name="PackageBody" sql:relation="FE_PackageBody">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="InvestmentVehicle" sql:relation="FE_InvestmentVehicle" sql:relationship="PackageBody-InvestmentVehicle">
                <xs:complexType>
                  <xs:sequence>
                    <xs:choice maxOccurs="unbounded">
                      <xs:element minOccurs="0" name="Operation" sql:relation="FE_Operation" sql:relationship="InvestmentVehicle-Operation">
                        <xs:complexType>
                          <xs:sequence>
                            <xs:choice maxOccurs="unbounded">
                              <xs:element minOccurs="0" name="InvestmentVehicleName" type="xs:string" />
                              <xs:element minOccurs="0" name="ShareClassId" type="xs:string" />
                              <xs:element minOccurs="0" name="LegalType" type="xs:string" />
                              <xs:element minOccurs="0" name="OldestShareClass" sql:relation="FE_OldestShareClass" sql:relationship="Operation-OldestShareClass">
                                <xs:complexType>
                                  <xs:sequence>
                                    <xs:element minOccurs="0" name="Name" type="xs:string" />
                                    <xs:element minOccurs="0" name="Id" type="xs:string" sql:field="OldestShareClassId"/>
                                  </xs:sequence>
                                </xs:complexType>
                              </xs:element>

The Bulk Load operation runs fine up until it sees the "xs:choice" element.  Everything outside the xs:choice element gets imported just fine.  Everything nested within the "choice" element gets ignored by Bulk Upload.  If I comment out the choice element, I get an invalid cast error because XMLBulkLoad tries to do a sequential data import which means that input data is directed to the wrong table.

There has to be a way to get this to work!  Please help!

75d315edb24a8e741737f570c1e5f0d3

Submitted under: Microsoft SQL Server · XML · BCP ·  · 


hunterjl
1554 · 0% · 12

1 Replies

  • Hi Hunter,

    Sorry for the late reply. XMLBulkload will not support xs:choice. The only way is to change your XSD. If you already solves the problem, can you please let us know, what is the solution, so that others can benefit. If not, can you tell us the scenario, that u r using the "choice" element here.

    commented on May 24 2011 11:13PM
    Ramireddy
    2 · 41% · 12972

Your Reply


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]