Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 XML Bulk Load into 3 tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-29 : 08:48:57
Greg writes "Hi

I modified an example given with SQLXML 3(service pack1) to load an XML file into 3 related tables and got an error.

Here is the description:

CREATE TABLE Cust (
CustomerID int PRIMARY KEY,
CompanyName varchar(20) NOT NULL,
City varchar(20) DEFAULT 'Seattle')
GO
CREATE TABLE CustOrder (
OrderID int PRIMARY KEY,
CustomerID int FOREIGN KEY REFERENCES
Cust(CustomerID))
GO

CREATE TABLE CustPeople (
PersonID int PRIMARY KEY,
CustomerID int FOREIGN KEY REFERENCES
Cust(CustomerID))
GO

Here is a file SampleXMLData3.xml to load:

<ROOT>
<Customers>
<CustomerID>1111</CustomerID>
<CompanyName>Hanari Carnes</CompanyName>
<City>NY</City>
<Order OrderID="1" />
<Order OrderID="2" />
<Person PersonId="21" />
<Person PersonId="23" />
</Customers>

<Customers>
<CustomerID>1112</CustomerID>
<CompanyName>Toms Spezialitten</CompanyName>
<City>LA</City>
<Order OrderID="3" />
<Person PersonId="123" />
<Person PersonId="156" />
</Customers>
<Customers>
<CustomerID>1113</CustomerID>
<CompanyName>Victuailles en stock</CompanyName>
<Order OrderID="4" />
<Person PersonId="267" />
<Person PersonId="289" />
</Customers>
</ROOT>


Here is the content of SampleSchema3.xml file:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="CustCustOrder"
parent="Cust"
parent-key="CustomerID"
child="CustOrder"
child-key="CustomerID" />
<sql:relationship name="CustCustPeople"
parent="Cust"
parent-key="CustomerID"
child="CustPeople"
child-key="CustomerID" />
</xsd:appinfo>
</xsd:annotation>

<xsd:element name="Customers" sql:relation="Cust" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CustomerID" type="xsd:integer" />
<xsd:element name="CompanyName" type="xsd:string" />
<xsd:element name="City" type="xsd:string" />
<xsd:element name="Order"
sql:relation="CustOrder"
sql:relationship="CustCustOrder" >
<xsd:complexType>
<xsd:attribute name="OrderID" type="xsd:integer" />
</xsd:complexType>
</xsd:element>


<xsd:element name="Person"
sql:relation="CustPeople"
sql:relationship="CustCustPeople" >
<xsd:complexType>
<xsd:attribute name="PersonID" type="xsd:integer" />
</xsd:complexType>
</xsd:element>


</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


When I execute a vbscript to load the XML data in the db, I get an error

"<?xml version="1.0"?><Result State="FAILED"><Error><HResult>0x80004005</HResult><Description><![CDATA[No data was provided for column 'PersonID' on table 'CustPeople', and this column cannot contain NULL values.>></Description><Source>General operational error</Source><Type>FATAL</Type></Error></Result>

Please, help! What is wrong with the schema?"

gopalvengadam
Starting Member

1 Post

Posted - 2004-09-14 : 18:35:51
Hi Greg,

I Know its too late for a reply to this thread; but just curious how you solved the issue (if you remember)

I have the same error when use C# to do Bulk Load..

-- Gopal

----------------
Gopal Thiruvengadam
Go to Top of Page
   

- Advertisement -