在groovy中解析多个XML标记并插入到Oracle数据库中

时间:2018-05-29 12:06:55

标签: groovy xml-parsing

我需要递归地读取XML中的多个标签。我已经在Groovy的ODI中编写了这段代码,它没有给出任何错误但也没有给出任何输出。它应该在我的数据库中插入2行,查看xml,但它没有插入。似乎是标签层次结构的问题。请帮帮我。

xml文件: enter image description here

groovy代码:

 File SFDCResponseFile = new File("/drxe2o/admin/Integration/odi/reference_data/sfdc/copy_center/Sample.xml")
        if (!SFDCResponseFile?.exists()) {
            throw new RuntimeException("No SFDC Query Response file ${SFDCResponseFile.absolutePath}")
        }

   def myCon = odiRef.getJDBCConnection("SRC")
   def myStmt = myCon.createStatement()

    def slurper = new XmlSlurper().parse(SFDCResponseFile)

slurper.queryResponse.result.records.each
{
            myStmt.executeUpdate("INSERT INTO <%=odiRef.getSchemaNameDefaultPSchema("LS_ODI_WORK","D")%>.RX_ODI_TAGVALUE_TEMP " +
                "(EVENT_CODE,EVENT_EDITION,ORDER_SUMMARY_NUMBER) " +
                "VALUES ('${it.Event_Code__c.text()}','${it.Event_Edition__c.text()}','${it.Order_Summary_Number__c.text()}')")
}

0 个答案:

没有答案