Using Schemas | XML Data Type | Teradata Vantage - Using Schemas - Advanced SQL Engine - Teradata Database

XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
amr1556233250442.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1140
lifecycle
previous
Product Category
Teradata Vantageā„¢

The CREATESCHEMABASEDXML and ISSCHEMAVALID methods accept a schema as an argument. For XML schemas that are composed of a single schema document (the schema document does not include or import another schema document), you can pass the schema document as an XML type value to the method. For XML schemas that are made up of more than one document, you must pass the consolidated schema document as an XML type value to the method.

You can store the schema or consolidated schema document in a table and use it in a query that performs schema validation through a join as follows:

SELECT customerID, customerXML.ISSCHEMAVALID(schematab.schemacontent, 'Customer', '')
FROM customer, schematab
WHERE schematab.schemaid = 'customerschema.xsd';

If you want to perform multiple validations per row, you can use subqueries of the following form:

SELECT x.xmlcol1.isschemavalid(s1.schemacontent, '', ''),
   x.xmlcol2.isschemavalid(s2.schemacontent, '', '')
FROM xmldata x,
   (select st.schemacontent
    from schematab st
    where st.schemaid = 'myFirstSchema.xsd') s1,
   (select st.schemacontent
    from schematab st
    where st.schemaid = 'mySecondSchema.xsd') s2;