0

将 fixwidth 文件导入带有 scriptella 的表的最佳方法是什么?

文本文件:

blabla bloblo ble    bli

列宽:

(1,7) (8,14) (15,21) (22,24)

桌子:

T_IMPORT (
  FIELD1 VARCHAR(8),
  FIELD2 VARCHAR(8),
  FIELD3 VARCHAR(8),
  FIELD4 VARCHAR(4)
)
4

1 回答 1

0

我想出的解决方案是:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <connection id="database" url="jdbc:hsqldb:mem:mymemdb" user="SA" password=""/>
    <connection id="in" driver="text" url="${filePath}test_import.txt" />
    <query connection-id="in">
            <script connection-id="database">
                INSERT INTO T_IMPORT 
                VALUES (
                ?{column0.substring(0,7)},
                ?{column0.substring(8,14)},
                ?{column0.substring(15,21)},
                ?{column0.substring(22,24)});
        </script>
    </query>
</etl>
于 2013-03-12T13:43:33.790 回答