XML Import txt file to to SQL. Duplicate id error message? - sql

My administrative program uses an xml-file to import pricelists (txt files) to the SQL database.
There is a lot of rows in the XML file but this is the rows I have problems with.
<?xml version="1.0"?>
<BCPFORMAT>
<RECORD>
<FIELD ID="41" xsi:type="CharFixed" LENGTH="5" COLLATION=""/>
</RECORD>
<ROW>
<COLUMN SOURCE="41" NAME="VGRNR1" xsi:type="SQLVARYCHAR"/>
<COLUMN SOURCE="41" NAME="VGRNR2" xsi:type="SQLVARYCHAR"/>
</ROW>
</BCPFORMAT>
I have changed the eighth row to COLUMN SOURCE="41" because I want the data from FIELD ID="41" in both fields VGRNR1 and VGRNR2 in the SQL database.
When I make the change I get this error message from my administrative program:
duplicate element id "41"
Is it possible to edit the xml-file so I can get data from FIELD ID="41" in both fields VGRNR1 and VGRNR2 in the database?

Related

JdbcSQLException: Referential integrity constraint violation [on delete]

I am setting up unit tests on my application, and that for I need to mockup the database so I am not altering the actual one.
So, I am using DBUnit to simulate a database based on a XML File :
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<ACTION_TYPE ID="1" NAME="INVALID_CPT"/>
<ACTION_TYPE ID="2" NAME="INTEGRATED_FLOW"/>
<ACTION_TYPE ID="3" NAME="CLOSING_TECHNICAL_FLOW"/>
<ACTION_TYPE ID="4" NAME="AUDIT_FLOW"/>
<ACTION_TYPE ID="5" NAME="VALIDATION_FLOW"/>
<ACTION_TYPE ID="6" NAME="RETURN_DRAFT_FLOW"/>
<USER_GROUP ID="1" NAME="AKA_CPT"/>
<USER_GROUP ID="2" NAME="AKA_ADMIN_SECU"/>
<USER_GROUP ID="3" NAME="AKA_CISO"/>
<USER_GROUP ID="4" NAME="AKA_ADMIN_NETWORK"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="1" USER_GROUP_ID="1"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="4" USER_GROUP_ID="1"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="6" USER_GROUP_ID="1"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="2" USER_GROUP_ID="2"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="3" USER_GROUP_ID="2"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="5" USER_GROUP_ID="2"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="5" USER_GROUP_ID="3"/>
<ACTION_USER_GROUP ACTION_TYPE_ID="2" USER_GROUP_ID="4"/>
</dataset>
This is just a part of the whole XML file, but this is where my problem come from.
I have these 2 objects ACTION_TYPE and USER_GROUP which are linked by a Many to Many relationship.
But as soon as I run my test code, I am getting this error:
org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FKFA9ACTE184RNO1RS40IW6E1LK: PUBLIC.ACTION FOREIGN KEY(USER_GROUP_ID) REFERENCES PUBLIC.USER_GROUP(ID) (2)"; SQL statement:
delete from USER_GROUP [23503-193]
I know what an integrity constraint violation is, but despite I do not think I made one in the XML file above.
Does someone know where this error is coming from, and maybe how I could fix it?
Thank you in advance

DateFormatTransformer not working with FileListEntityProcessor in Data Import Handler

While indexing data from a local folder on my system, i am using given below configuration.However the lastmodified attribute is getting indexed in the format "Wed 23 May 09:48:08 UTC" , which is not the standard format used by solr for filter queries .
So, I am trying to format the lastmodified attribute in the data-config.xml as given below .
<dataConfig>
<dataSource name="bin" type="BinFileDataSource" />
<document>
<entity name="f" dataSource="null" rootEntity="false"
processor="FileListEntityProcessor"
baseDir="D://FileBank"
fileName=".*\.(DOC)|(PDF)|(pdf)|(doc)|(docx)|(ppt)" onError="skip"
recursive="true" transformer="DateFormatTransformer">
<field column="fileAbsolutePath" name="path" />
<field column="fileSize" name="size" />
<field column="fileLastModified" name="lastmodified" dateTimeFormat="YYYY-MM-DDTHH:MM:SS.000Z" locale="en"/>
<entity name="tika-test" dataSource="bin" processor="TikaEntityProcessor"
url="${f.fileAbsolutePath}" format="text" onError="skip">
<field column="Author" name="author" meta="true"/>
<field column="title" name="title" meta="true"/>
<!--<field column="text" />-->
</entity>
</entity>
</document>
</dataConfig>
But there is no effect of transformer, and same format is indexed again . Has anyone got success with this ? Is the above configuration right , or am i missing something ?
Your dateTimeFormat provided does not seem to be correct. The upper and lower case characters have different meaning. Also the format you showed does not match the date text you are trying to parse. So, it probably keeps it as unmatched.
Also, if you have several different date formats, you could parse them after DIH runs by creating a custom UpdateRequestProcessor chain. You can see schemaless example where there is several date formats as part of auto-mapping, but you could also do the same thing for a specific field explicitly.

sql modify XML node

I'm trying to modify xml attribute in my table:
XML:
<root>
<object name="111">
<fields>
<field name="1">False</ofield>
<field name="VIN">123</field>
</fields>
</object>
</root>
UPDATE wftable
SET XML.modify('replace value of
(root/object[#name="111"]/fields/field/#name[.="VIN"])[1]
with "testNumber"')
WHERE id = 20889436
But I get as a result
<field name="testNumber">123</field>
Actually I just want to update xml node like this:
<field name="VIN">testNumber</field>
How can I modify my UPDATE query?
You need to specify the text() node of field as the node you want to update.
replace value of
(root/object[#name="111"]/fields/field[#name="VIN"]/text())[1]
with "testNumber"

Mule ESB: Issue w/ XML generated from MapsToXML input to DataMapper

I have a JDBC outbound endpoint that after performing Map To XML transformation, gives out XML in the following format:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<record>
<field name="DESTINATION" type="java.lang.String">SFO</field>
<field name="PRICE" type="java.lang.String">500</field>
<field name="ID" type="java.lang.Integer">2</field>
</record>
</table>
The problem is that when I try to generate the schema for this XML for use in the datamapper , the fields that are generated from this are not usable (it only shows field , In the mapping file I get this message when I try to hover over it :
'The attribute cannot be dragged since it does not belong to 'Current Element Mapping'
How do I use my XML so that I can map those fields to either another CSV, database or some other entity?
Why not trying to map (via DataMapper) Map object directly to CSV or anything you'd like ? If you need this intermediary XML format, you can also use DataMapper for the initial Map->XML mapping and configure the way you want it to look like (instead using MapsToXML).

How to update a lookup field using a web service

I have a Nintex workflow and I am using a "Call Web Service" action to add a new list item in another site. I want to update a lookup field in the destination list from a lookup field in the source list. This is my CAML query
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>Kaizen Blast Objectives</listName>
<updates>
<Batch OnError="Continue" ListVersion="1" ViewName="">
<Method ID="1" Cmd="New">
<Field Name="ID">New</Field>
<Field Name="Title">{ItemProperty:Title}</Field>
<Field Name="Event_x0020_Driver">{ItemProperty:Event_x0020_Driver}</Field>
<Field Name="Problem_x0020_Statement">{ItemProperty:Problem_x0020_Statement}</Field>
<Field Name="Group1">{ItemProperty:Group}</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
"Group1" is a lookup field in the destination list and "Group" ({ItemProperty:Group}) is a lookup field in the source list.
A simple assignment like I have doesn't seem to work.
EDIT
The lookup field in the destination list is a site column.
Any ideas?
I figured it out. When updating a lookup field the format has to be id;#value. This is true even if the source and the destination fields are of the same data type.