简体   繁体   中英

MySQL LOAD XML LOCAL INFILE inserting 0 rows

I know several variations of this question have been asked in the past and I've searched, but I still am running into an issue. It's probably something I'm just simply overlooking.

I have a webapp that saves records to a xml file when someone deletes are record. It's using the mysqldump to create the xml record. I need to import a deleted record back and I'm using this:

mysql> LOAD XML LOCAL INFILE "c:\loadthis.xml" into table mytable; I get: Query OK, 0 rows affected (0.00) Records: 0 Deleted: 0 Skipped: 0 Warning: 0

Any ideas what I could be doing wrong? I verified the ID does not exist in the table.

This is what the xml file looks like (I deleted a lot of the columns for security). The table has 159 columns and the xml file correlates correctly to the table.

<?xml version="1.0"?>

<SQL stmt="select * from mytable where ID=107336">
    <row>
        <ID DATATYPE="INT UNSIGNED" DATAWIDTH="10" NULL="NOTNULL">107336</ID>
        <CREATEDBY DATATYPE="VARCHAR" DATAWIDTH="75" NULL="NOTNULL">rg</CREATEDBY>
        <CREATEDATE DATATYPE="DATETIME" DATAWIDTH="19" NULL="NOTNULL">2019-11-05 11:17:21.0</CREATEDATE>
        <MODIFIEDBY DATATYPE="VARCHAR" DATAWIDTH="75" NULL="NOTNULL">jl</MODIFIEDBY>
        <MODIFIEDDATE DATATYPE="DATETIME" DATAWIDTH="19" NULL="NOTNULL">2019-11-06 12:23:22.0</MODIFIEDDATE>
        <OWNER DATATYPE="VARCHAR" DATAWIDTH="75" NULL="NULL">rg</OWNER>
        <DELETED DATATYPE="VARCHAR" DATAWIDTH="15" NULL="NULL"></DELETED>
        <FIRSTNAME DATATYPE="VARCHAR" DATAWIDTH="200" NULL="NULL">John</FIRSTNAME>
        <LASTNAME DATATYPE="VARCHAR" DATAWIDTH="200" NULL="NULL">Smith</LASTNAME>
</row>
</SQL>

Ok, the issue is that there was an & in one of the data fields in the file that wouldn't load. Not sure why that would be an issue. I just deleted the character from the xml file, loaded the file then added the character back after it inserted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM