How in insert data into Empty XML Schema using XQuery

Hello Guys!

I am a beginner in Tamino XML server. Here are some questions i got for the last time. Could you please help me to find our the reason of my problem

I needed to perform a migration from MS SQL database to XML server storage. I decided not to use Tamigo Schema ODBC Wizard and desided to define a schema by my own.

  1. I downloaded and installed a 30 days eval version of the Tamino XML server.

  2. I created my own database. (by the way I found that eval version does not allow to set the created database AutoStart to YES - is it so?) The mininal sized database was created due to the fact that the eval version allows to create only such kind of database. The Database name was test.
    The database started fine.

  3. I declared a schema presented below (a test one in general there will be more types of document (the same as number of tables)):

<?xml version = "1.0" encoding = "UTF-8"?>

<xs:schema xmlns:tsd = “http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition” xmlns:xs = “http://www.w3.org/2001/XMLSchema”>
xs:annotation
xs:appinfo
<tsd:schemaInfo name = “tst”>
<tsd:collection name = “tst”></tsd:collection>
<tsd:doctype name = “TW”>
tsd:logical
tsd:contentopen</tsd:content>
</tsd:logical>
</tsd:doctype>
<tsd:doctype name = “RD_CUSTOMER”>
tsd:logical
tsd:contentopen</tsd:content>
</tsd:logical>
</tsd:doctype>
<tsd:doctype name = “RD_EMP”>
tsd:logical
tsd:contentopen</tsd:content>
</tsd:logical>
</tsd:doctype>
tsd:adminInfo
tsd:server4.1.4.1</tsd:server>
tsd:modified2005-07-12T16:13:28.703+06:00</tsd:modified>
tsd:created2005-07-06T12:04:19.109+06:00</tsd:created>
tsd:versionTSD4</tsd:version>
</tsd:adminInfo>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
<xs:simpleType name = “char2”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “2”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “datetime8”>
<xs:restriction base = “xs:dateTime”></xs:restriction>
</xs:simpleType>
<xs:simpleType name = “int4”>
<xs:restriction base = “xs:integer”></xs:restriction>
</xs:simpleType>
<xs:simpleType name = “smallint2”>
<xs:restriction base = “xs:integer”></xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar1”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “1”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar100”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “100”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar1024”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “1024”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar12”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “12”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar128”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “128”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar18”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “18”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar20”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “20”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar256”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “256”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar32”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “32”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar40”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “40”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “varchar64”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “64”></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name = “text16”>
<xs:restriction base = “xs:string”>
<xs:maxLength value = “16”></xs:maxLength>
</xs:restriction>
</xs:simpleType>

<xs:element name = “TW”>
xs:complexType
xs:sequence
<xs:element ref = “RD_CUSTOMER” maxOccurs = “unbounded”></xs:element>
<xs:element ref = “RD_EMP” maxOccurs = “unbounded”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = “RD_CUSTOMER”>
xs:complexType
xs:sequence
<xs:element name = “CUSTID” type = “int4”></xs:element>
<xs:element name = “CUSTCODE” type = “varchar12”></xs:element>
<xs:element name = “CUSTNAME” type = “varchar64”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = “RD_EMP”>
xs:complexType
xs:sequence
<xs:element name = “EMPID” type = “int4”></xs:element>
<xs:element name = “EMPCODE” type = “varchar12”></xs:element>
<xs:element name = “EMPNAME” type = “varchar64”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

I decided not to use Tamino Manager ODBC Wizard and to create a schema by hands.

  1. I verified and defined this schema on the server using Tamino Schema Manager Tool.

After that i started the XQuery tool to check if i can insert any data into the empty schema i just defined. The queries i tried are:

update insert
<RD_CUSTOMER>
23423234
CUSTCODE
ITYis a test customer
</RD_CUSTOMER>
into input()/RD_CUSTOMER

update insert
<RD_CUSTOMER>
23423234
CUSTCODE
ITYis a test customer
</RD_CUSTOMER>
into input()/TW

update insert
<RD_CUSTOMER>
23423234
CUSTCODE
ITYis a test customer
</RD_CUSTOMER>
<RD_EMP>
23423234
CUSTCODE
ITYis a test customer
</RD_EMP>
into input()/TW

After every query is processed NO errors are deceived in server respond, Every time is says like:

<?xml version="1.0" encoding="windows-1251" ?>

update insert
<RD_CUSTOMER>
23423234
CUSTCODE
ITYis a test customer
</RD_CUSTOMER>
into input()/TW

]]>
</xq:query>

But if i open XPloirer after that or use queries like:

for $b in input()/TW return $b

for $b in input()/RD_CUSTOMER return $b

for $b in input()/RD_EMP return $b

THE SERVER RETURNDS NO RECORDS.

I am going to use Tamino API for C and in this case i plane to use XQuery. That is why i am trying to

The questions:
1.Is there any errors in my schema which do not allow me to insert the data using XQuery?
2. What should be present in schema (what elements or doctypes) and how if i need to store a big number of Instances of every document ( RD_CUSTOMER or RD_EMP). I tried to define TW doctype to use it as a docs storage for the other doc types but it seems it is declared wrong
3. Is there a possibility to insert data into an empty schema using only XQuery or must the schema be prepared some how before by using Data Loader service (first Doc Instances must be imported or some)

Thank you in advance
tst.tsd (4.6 KB)

Hi,

you cannot insert documents via XQuery. The “insert” in the XQuery update sublanguage is used to insert nodes into existing documents. To insert documents into Tamino, use the data loader, the _process statement (or its equivalent in one of the APIs), the interactive interface or the Tamino X-Plorer

Regards

Harald