0

how's goin'? I have to use an xml file like a database and i should import the xml in H2 database but the most of command syntax of basic sql it's not working on H2 and the XML type is not supported, so how can i import the xml?

This is the xml sample

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <Customers>
        <Customer CustomerName="Arshad Ali" CustomerID="C001">
            <Orders>
                <Order OrderDate="2012-07-04T00:00:00" OrderID="10248">
                    <OrderDetail Quantity="5" ProductID="10" />
                    <OrderDetail Quantity="12" ProductID="11" />
                    <OrderDetail Quantity="10" ProductID="42" />
                </Order>
            </Orders>
            <Address> Address line 1, 2, 3</Address>
        </Customer>
        <Customer CustomerName="Paul Henriot" CustomerID="C002">
            <Orders>
                <Order OrderDate="2011-07-04T00:00:00" OrderID="10245">
                    <OrderDetail Quantity="12" ProductID="11" />
                    <OrderDetail Quantity="10" ProductID="42" />
                </Order>
            </Orders>
            <Address> Address line 5, 6, 7</Address>
        </Customer>
        <Customer CustomerName="Carlos Gonzlez" CustomerID="C003">
            <Orders>
                <Order OrderDate="2012-08-16T00:00:00" OrderID="10283">
                    <OrderDetail Quantity="3" ProductID="72" />
                </Order>
            </Orders>
            <Address> Address line 1, 4, 5</Address>
        </Customer>
    </Customers>
</ROOT>

I found the bulk operation for single_blob, but h2 stop me before, on simple create table that dislike the xml data type. Tutorial works on sql server but i haven't find none on H2 db...

cloud.f
  • 1
  • 2
  • Do you have an XML example, the SQL that's not working, and the database on which it works? most standard SQL works on H2, but since XML is not a standard import, we need context. – pdem Sep 29 '22 at 12:55
  • @pdem CREATE TABLE xmlOpen (id int identity, dataDb xml) A simple create table that on MSql management studio it works, but on h2 is not supported, i'm looking for tutorial but any work on h2, i'm not a senior so probably i miss some of content – cloud.f Sep 29 '22 at 13:03
  • Is you have your mysql database, it's better to export as sql, then fix some incompatibilities to import to H2, som explanation here: https://stackoverflow.com/questions/11610850/convert-mysql-script-to-h2 – pdem Sep 29 '22 at 13:12
  • @pdem so i must have to do it this way? Force to convert from another db to h2? – cloud.f Sep 29 '22 at 13:50
  • sql files are standard, so it's not converting to H2 but more converting to SQL. This file will also be importable to mysql, postgresql. If you are in a unit test, you can also use dbunit that manage XML, but that's an edge case. – pdem Sep 29 '22 at 13:56
  • ok thanks, so there's not any other way to do that? I mean, directly on h2 with its syntax – cloud.f Sep 29 '22 at 14:30

0 Answers0