我想使用 scriptella 将数据从 oracle 复制到 postgresql 数据库。但是我有一个 tel 列,在两个数据库中有不同的类型,一个是 varchar,另一个是大 int,我怎样才能在这里隐式转换是 etl 文件。
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>
test script
</description>
<connection id="in" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:XE"
user="test" password="test">
</connection>
<connection id="out" driver="postgresql"
url="jdbc:postgresql://localhost:5432/testMonoprix2" user="postgres"
password="maher">
</connection>
<query connection-id="in">
SELECT LIBELLE, ADRESSE,MATFISC,CONTACT,TEL FROM IPTECH.TMP_FOURNISSEUR;
<script connection-id="out">
UPDATE public.suppliers SET is_enabled='TRUE', label=?LIBELLE, address=?ADRESSE, tax_registration_number=?MATFISC,contact=?CONTACT, tel=?TEL;
</script>
</query>
</etl>
这是java代码
这是我得到的错误
import java.io.File;
import scriptella.execution.EtlExecutor;
import scriptella.execution.EtlExecutorException;
public final class Test_Scriptella
public static void main(String[] args) throws EtlExecutorException {
try {
EtlExecutor.newExecutor(new File("oracle_etl.xml")).execute();
System.out.println("file executed");
}catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
}
这是我得到的错误
Location: /etl/query[1]/script[1]
JDBC provider exception: Unable to execute statement
Error statement:
UPDATE public.suppliers SET is_enabled='TRUE', label=?, address=?, tax_registration_number=?,contact=?, tel=?. Parameters: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, MONOPRIX LAFAYETTE, null, Neant, 891 656 ]
Error codes: [42804, 0]
Driver exception: org.postgresql.util.PSQLException: ERREUR: la colonne « tel » est de type bigint mais l'expression est de type character varying
Hint: Vous devez réécrire l'expression ou lui appliquer une transformation de type.
Position: 114