首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用apache scriptella复制数据时发生数据类型冲突

使用apache scriptella复制数据时发生数据类型冲突
EN

Stack Overflow用户
提问于 2017-08-07 21:42:52
回答 1查看 61关注 0票数 0

我想复制数据从甲骨文到postgresql数据库使用脚本.But我有一个列tel,它在两个数据库中有不同的类型,一个是varchar,另一个是大整数,我如何才能转换隐含的数据这里是etl文件。

代码语言:javascript
复制
<!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代码

这是我得到的错误

代码语言:javascript
复制
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());
                }
        }
    }

下面是我得到的错误

代码语言:javascript
复制
 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-07 23:48:59

我还没有尝试过,但是一种选择是使用cast()函数将其转换为int:

代码语言:javascript
复制
UPDATE public.suppliers  SET is_enabled='TRUE', label=?LIBELLE, address=?ADRESSE, tax_registration_number=?MATFISC,contact=?CONTACT, tel=cast(?TEL as bigint);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45548423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档